This is the mail archive of the
mailing list for the pthreas-win32 project.
Re: starvation in pthread_once?
On Tue, 8 Mar 2005 18:14:22 +0100, Alexander Terekhov
> > It would just seem like overkill if all my mutexes needed a
> > mutex to init themselves.
> With CAS (InterlockedCompareExchange), you can use lockless
> DCCI (not DCSI) on slow path to initialize event handle/ptr.
Yes, I remember that conversion. I've improved my stuff because of it
no doubt. But in those examples, the slow path was still taken by the
first thread (IIRC - it was because your lock starts out == 0 ie
contention.) Whereas my version (above, in this thread) avoids the
event creation entirely if there is no contention while initting (ie
first one in does the init, but doesn't create event - only triggers the event
if it finds one there when initting is done).
I'd like to hear your opinion - yours in particular, actually (or
wrath - particularly wrath if necessary. If there is a problem I need
someone to tell me - threading code is not reliable because of
testing, but because of peer review).