From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12555 invoked by alias); 8 Mar 2005 18:28:13 -0000 Mailing-List: contact pthreads-win32-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sources.redhat.com Received: (qmail 11719 invoked from network); 8 Mar 2005 18:27:58 -0000 Received: from unknown (HELO rproxy.gmail.com) (64.233.170.205) by sourceware.org with SMTP; 8 Mar 2005 18:27:58 -0000 Received: by rproxy.gmail.com with SMTP id c51so1530333rne for ; Tue, 08 Mar 2005 10:27:58 -0800 (PST) Received: by 10.38.181.13 with SMTP id d13mr36193rnf; Tue, 08 Mar 2005 10:27:53 -0800 (PST) Received: by 10.54.7.8 with HTTP; Tue, 8 Mar 2005 10:27:53 -0800 (PST) Message-ID: <97ffb3105030810275ac6f5c@mail.gmail.com> Date: Tue, 08 Mar 2005 18:28:00 -0000 From: Gottlob Frege Reply-To: Gottlob Frege To: Alexander Terekhov Subject: Re: starvation in pthread_once? Cc: Pthreads-Win32 list In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <97ffb31050308081116245b75@mail.gmail.com> X-SW-Source: 2005/txt/msg00040.txt.bz2 On Tue, 8 Mar 2005 18:14:22 +0100, Alexander Terekhov 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).