public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] No binary semaphore in C API?
@ 2001-03-16 12:01 Grant Edwards
  2001-03-19 13:42 ` Jonathan Larmour
  0 siblings, 1 reply; 23+ messages in thread
From: Grant Edwards @ 2001-03-16 12:01 UTC (permalink / raw)
  To: ecos-discuss

Hi all,

I see that the kernel impliments binary semaphores, but I can't
see a C API for them.  I've got a mutual-exclusion requirement
but can't use cyg_mutex_t because one thread locks and a
different thread unlocks the resource.  [It's kind of
complicated, the mutal exclusion is between two "groups" of
threads.]

So, I wanted to use binary semaphores, but can't find the API.
The program is using counting semaphores right now, but using a
binary ones would be a bit more "defensive".

Is there a technical reason that there isn't a C API for binary
semaphores, or is it something that just hasn't been done yet?

-- 
Grant Edwards
grante@visi.com

^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: [ECOS] No binary semaphore in C API?
@ 2001-03-30  5:39 Rosimildo daSilva
  0 siblings, 0 replies; 23+ messages in thread
From: Rosimildo daSilva @ 2001-03-30  5:39 UTC (permalink / raw)
  To: ecos-discuss

>From: Sergei Organov <osv@javad.ru>
>To: bartv@redhat.com
>CC: ecos-discuss@sourceware.cygnus.com
>Subject: Re: [ECOS] No binary semaphore in C API?
>Date: 30 Mar 2001 14:22:43 +0400
>

>I think that original post has a scenario for which there is no primitive 
>in
>eCos that exactly matches requirements and there will never be one I guess 
>as
>the problem that should be solved is rather complex and hopefully
>rare. Somebody (you?) described it as "mutual exclusion between thread
>groups". For me it belongs to the same class as read-write locks but
>apparently is even more complicated. One of solutions, IMHO, is to 
>implement
>special object on top of primitives that eCos provides and use it in the
>application. Then it will be this object that will take care of preserving
>semantics of eCos primitives it uses. And if it is possible to build it on 
>top
>of current binary semaphore, it is also possible to build it on top of 
>current
>counting semaphore, I believe.
>
>I'm still not convinced that tuning eCos primitive for such questionable 
>usage
>is a good idea especially as it prohibits another possible application.
>


I believe that the primitive(s) that Sergei was talking about
is more in line with the semantic of the WIN32/OS/2 "Event"
primitives. Something that has a semantic of a switch ( on/off ).

This semaphore, called from now "EventX", has two states,

  + Reseted, Posted.

Once reseted, any thread "waiting" on that semaphore will block. Once,
the semaphore is "posted", all threads are unblocked, and it remains on that 
state until it is explicited put back on the "Reseted" state.

Interface:

  class EventX
  {
    public:

    void post();
    bool wait( some timeout here );
    void reset();
  };

As he mentioned on the first message, this type of primitive
is very handy, because you do not need a "thread id" of the
receiving thread to be used. I have used the "Binary"
semaphores to archieve this semantic in some cases,
but they never matches 100%.

Rosimildo.


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2001-03-30  7:42 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-16 12:01 [ECOS] No binary semaphore in C API? Grant Edwards
2001-03-19 13:42 ` Jonathan Larmour
2001-03-26  3:53   ` Nick Garnett
2001-03-26  7:12     ` Fabrice Gautier
2001-03-26 11:37     ` Grant Edwards
2001-03-27  2:00       ` Nick Garnett
2001-03-27  5:32         ` Grant Edwards
2001-03-28  5:29         ` Bart Veer
2001-03-28  6:45           ` Sergei Organov
2001-03-28  7:38             ` Grant Edwards
2001-03-28  7:39             ` Bart Veer
2001-03-28 10:01               ` Jonathan Larmour
2001-03-28 10:01               ` Sergei Organov
2001-03-28 11:05                 ` Grant Edwards
2001-03-29 11:51                   ` Sergei Organov
2001-03-29 11:49                     ` Grant Edwards
2001-03-29 11:55           ` Chris Gray
2001-03-29 19:33             ` Bart Veer
2001-03-29 20:50               ` Grant Edwards
2001-03-30  2:22               ` Sergei Organov
2001-03-30  6:54                 ` Grant Edwards
2001-03-30  7:42                   ` Sergei Organov
2001-03-30  5:39 Rosimildo daSilva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).