This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: No binary semaphore in C API?


Bart Veer wrote:

> Arguably there should be an assert in Cyg_Binary_Semaphore::post(),
>
>     CYG_ASSERT( false == state, "Posting to unlocked binary semaphore");
>
> However I am not sure that there is sufficient agreement on the
> general semantics of binary semaphores to make that assertion valid.
> Some people might expect multiple posts to be a no-op. IMO the absence
> of completely clear semantics for a synchronization primitive is a
> good argument for removing that primitive completely.

As I understand it, the theoretical semantics of a binary semaphore is that

you "cannot" post to it twice.  To the theoretician, the question of what
happens
when something that can't happen happens is purely hypothetical.

In the system I'm currently working on (which uses ThreadX, but may one day

move to eCos), we have a macro assertSemaphore which is most often used in
the form "assertSemaphore(&s,1)" -- in other words to check that binary
semaphore semantics are being respected. So maybe such an optional runtime
check is all you need to add to counting semaphores to make them usable as
binary ones.

Regards

Chris



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]