This is the mail archive of the pthreads-win32@sources.redhat.com mailing list for the pthreas-win32 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: starvation in pthread_once?


On Tue, 8 Mar 2005 18:14:22 +0100, Alexander Terekhov
<TEREKHOV@de.ibm.com> wrote:
> 
> > 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.
> 
> http://www.google.de/groups?selm=421F44B2.F931491D%40web.de
> 
> regards,
> alexander.
> 

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).


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