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]
Other format: [Raw text]

Re: binary semaphores from counting or mutex


>>>>> "Aaron" == Aaron Case <aaron.case@dynazign.com> writes:

    Aaron> eCos Admiralty,
    Aaron> I am porting an application to eCos that was originally
    Aaron> written in embedded OS that used binary semaphores. The C
    Aaron> api implements counting semaphores.

    Aaron> As stated in the philosophical tear on the mailing list and
    Aaron> evident from API descriptions in the Massa text, counting
    Aaron> semaphores initialized to 1 are functionally equivalent to
    Aaron> binary semaphores.

    Aaron> Another alternative is to use mutexes, or binary semaphores
    Aaron> with ownership, in place of the binary semaphore
    Aaron> implementation of the code.

    <snip>

There is one point which I don't think has been raised yet: mutexes
are a very different synchronization primitive from semaphores, they
cannot be used interchangeably. See the "Synchronization Primitives"
section in the Kernel Overview part of the reference manual. A mutex
should be used only for locking access to a shared resource: a thread
locks the mutex prior to the access and that same thread unlocks the
mutex after the access. A semaphore is a way of signalling events: one
thread waits on the semaphore, then another thread or a DSR posts that
semaphore to indicate an event has happened.

According to a later posting you have four threads waiting for an
event, so mutexes are the wrong primitive for this application.

Bart

-- 
Bart Veer                       eCos Configuration Architect
http://www.ecoscentric.com/     The eCos and RedBoot experts

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


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