From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16659 invoked by alias); 16 Sep 2009 15:38:31 -0000 Received: (qmail 16643 invoked by uid 22791); 16 Sep 2009 15:38:30 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-bw0-f207.google.com (HELO mail-bw0-f207.google.com) (209.85.218.207) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 16 Sep 2009 15:38:26 +0000 Received: by bwz3 with SMTP id 3so3469489bwz.26 for ; Wed, 16 Sep 2009 08:38:23 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.84.1 with SMTP id m1mr3903314mul.34.1253115503446; Wed, 16 Sep 2009 08:38:23 -0700 (PDT) In-Reply-To: <97ffb3105032209269b0f44e@mail.gmail.com> References: <97ffb31050308081116245b75@mail.gmail.com> <1110768429.20103.115.camel@desk.home> <97ffb310503140832401faa2b@mail.gmail.com> <1110842168.21321.78.camel@desk.home> <97ffb3105031415473a3ee169@mail.gmail.com> <1110855601.21321.203.camel@desk.home> <97ffb31050321080747aa5a7c@mail.gmail.com> <1111464847.8363.91.camel@desk.home> <97ffb3105032209269b0f44e@mail.gmail.com> Date: Wed, 16 Sep 2009 15:38:00 -0000 Message-ID: <97ffb310909160838v6671abccv3b230ec213e66057@mail.gmail.com> Subject: Re: starvation in pthread_once? From: Gottlob Frege To: Ross Johnson , pthreads-win32@sources.redhat.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact pthreads-win32-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sourceware.org X-SW-Source: 2009/txt/msg00047.txt.bz2 Blast from the past - whatever happened to changing call_once() to not create the named mutex when it wasn't needed? On Tue, Mar 22, 2005 at 1:26 PM, Gottlob Frege wro= te: > If it comes down to it, I might vote for daisy-chaining over > busy-looping (assuming the busy-looping is endless). =A0Remember, this > all started because the original implementation was polling/sleeping > on 'initted' - and if the busy-looping thread is high-priority, then > we are locked forever... > > > On Tue, 22 Mar 2005 15:14:07 +1100, Ross Johnson > wrote: >> On Mon, 2005-03-21 at 11:07 -0500, Gottlob Frege wrote: >> >> > So, it doesn't seem to be getting any easier! =A0*Almost* to the point >> > where a big named mutex becomes tempting - there is a lot to be said >> > for simplicity. =A0However, my/the goal is still to at least minimize >> > the non-contention simple init case... >> >> I'm less and less tempted to use a named mutex. Perhaps there's a >> standard technique, but AFAICS it's impossible to guarantee that the >> name is unique across the system (and all Windows variants). >> >> And I agree, minimum overhead for the uncontended case is the top >> priority (after correct behaviour). I'm not concerned at all about speed >> in the cancellation case. >> >> > And the event is still an auto-reset, although I no longer think it >> > really matters - I really haven't had the tenacity to think this stuff >> > through. =A0If it doesn't matter, manual-reset would be better, I think >> > - I don't like having 1 thread relying on another thread waking it up, >> > - for cases where the thread is killed, or strange thread priorities, >> > etc. >> >> It all looks to me like it will work. I don't recall, in the version >> that's in pthreads-win32 now, why I included eventUsers (++/--) in what >> you have as the __lock() sections. Maybe to save additional Atomic calls >> (bus locks). But now I realise [in that version - not yours] that waking >> threads can block unnecessarily when leaving the wait section. >> >> It probably doesn't matter if cancel_event is auto or manual. I think >> there will be at most one thread waiting on it. And, for 'event', like >> you I'm uncomfortable with daisy-chaining SetEvent() calls. >> >> The only problem with the alternative of using a manual-reset event is >> that some thread/s may busy-loop for a bit until an explicit reset >> occurs. It seems untidy, but it's probably more robust than daisy- >> chained SetEvents given the issues you've identified above. >> >> So I'm tempted to leave both events as manual-reset events. I'm also >> guessing that this busy-looping will be extremely rare - perhaps only >> when a new thread sneaks in to become initter, then suspends just inside >> while the first waiter is waking and heading back to the loop start. >> >> I'll run your design and let you know the results. >> >> Thanks. >> Ross >> >> >