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?



> > Beware though that a flag "setbits" has broadcast semantics
> > (which is what you want), so it will take time - perhaps a lot
> > of time - proportional to the number of threads that were
> > waiting.  *That*'s the reason using this primitive in a DSR
> > might be recommended against.
> 
> Setbits won't take any longer than a cond_broadcast for a given
> number of waiting threads, will it?  In my applications there's
> only one, but I don't want to limit it in case others want to
> have multiple waiting threads.

Setbits takes a little longer than a cond_broadcast 'cos it has to do
boolean arithmetic to determine whether to awaken each thread - but that
overhead is constant per thread *examined* (rather than per-thread
awakened), there's no N^2 effect or anything horrid like that.  It's linear
on Nthreads just like a cond_broadcast.

If you're only using one or a few threads, and only ever waiting on and
setting one bit I wouldn't worry about it.

	- Huge


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