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]

FW: binary semaphores from counting or mutex



-----Original Message-----
From: Aaron Case [mailto:aaron.case@dynazign.com]
Sent: Thursday, August 14, 2003 2:29 PM
To: sandeep
Subject: RE: [ECOS] binary semaphores from counting or mutex


Sandeep,

This is a single processor system, EP7312.

Company policy prohibits mailing any code, but its very simple test as
follows...

Create 4 threads that are all synchronized by one semaphore(initializied to
a value of 1).

The threads all wait for the semaphore right out of the gate. Each thread
consists of a infinite while loop that waits for the semaphore at the
beginning and posts at the end of the loop with a diagnostic message
between.

One would never code in such a way, but this does simulate a condition where
if 4 threads executing an infinite loop all jump on one resource.
Admittedly, a worse case scenario but, a possibility given the nature of our
application.

This seemingly inane test always ends by "locking the keys in the car."  The
semaphore count gets set to zero and all threads are waiting on after only
executing the one thread once.

If I add in thread delays to stagger execution of the four threads, then all
threads run beautifully and predictably.

The application has multiple data tables with multiple dependencies between
tables, some of which are accessed very often by a dozen plus threads.

Thanks and Regards,
Aaron Case


-----Original Message-----
From: sandeep [mailto:sandeep@codito.com]
Sent: Thursday, August 14, 2003 11:32 AM
To: Aaron Case; ecos-discuss@sources.redhat.com
Subject: Re: [ECOS] binary semaphores from counting or mutex


> I have noticed that with binary implementation of counting semaphores a
race
> conditions can occur and cause undefined behavior.  I was able to simulate
> an instance whereby 4 threads hit the same semaphore at nearly the same
> time, which resulted in undefined behavior. This is however, a worst case
> scenario.
 is it possible for you to mail the example instance code, that other
listers
can try out at their end.
also, did you come across the mentioned observation on single processor
configuration or multiple processor configuration?
--
sandeep



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.509 / Virus Database: 306 - Release Date: 8/12/2003



-- 
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]