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: Condition Variables w/o mutual exclusion?


On Tue, Oct 02, 2001 at 09:29:00PM +0100, Jonathan Larmour wrote:

> > This implies that the thread may be awakened spuriously when
> > the event it is waiting for hasn't happened, but the first
> > sentence says that the thread can only be awakened by a
> > signal/broadcast. I don't understand why the loop is required
> > -- under what conditions will the thread be awakened when it
> > shouldn't be?
> 
> When some other thread has satisfied the "condition" first.

Thanks. I was confusing "the condition" with "the condition
variable".  The assumption seems to be that the call to
signal/broadcast is not sufficient condition to wake up a
thread, and that there's some other condition (which is to be
protected by the mutex) involved.

> If your mutex is not really _used_ for protecting anything,

Well, I'm not using it for anything.  I thought maybe it was
needed internally by the cyg_cond_*() calls.

> you'll probably find you don't care.

That's the conclusion I've come to.  

In my case, the DSR is waking up a set of tasks thay _may_ have
something to do once the DSR completes.  The "have anything to
do" decisions are all dependant on the DSR having run, but
independant of each other.  The mutex is handy when the "have
anything to do" decisions are somehow mutually exclusive.

-- 
Grant Edwards
grante@visi.com


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