X-Recipient: archive-cygwin@delorie.com
X-Spam-Check-By: sourceware.org
Date: Wed, 10 Mar 2010 10:12:52 -0500
From: Christopher Faylor <cgf-use-the-mailinglist-please@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Cygwin 1.7: Concurrency Issue with Shared State Initialization
Message-ID: <20100310151252.GC19509@ednor.casa.cgf.cx>
Reply-To: cygwin@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
References: <B10B50309DC54D45A855FD66F56015F71D07D2ABBC@DEWDFECCR03.wdf.sap.corp>  <20100310095929.GY6505@calimero.vinschen.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20100310095929.GY6505@calimero.vinschen.de>
User-Agent: Mutt/1.5.20 (2009-06-14)
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

On Wed, Mar 10, 2010 at 10:59:29AM +0100, Corinna Vinschen wrote:
>On Mar 10 10:55, Schmidt, Oliver wrote:
>> Hi Corrina,
>> 
>> Thanks for your involvement :-)
>> 
>> >> [...] a spinlock [...] With
>> >> InterlockedCompareExchange() and Sleep() it should be quite simple to
>> >> create one that's very efficient in the usual scenario.
>> 
>> > Does the below patch fix this for you?
>> 
>> I'll test the snapshot asap!
>> 
>> [...]
>> +      LONG init = InterlockedCompareExchange (&installation_root_init, 1L, 0L);
>> [...]
>> +	  low_priority_sleep (0);
>> [...]
>> 
>> I see we were thinking along the same lines ;-)
>
>The final patch is from cgf.  It's probably more performant since it
>drops the requirement for an additional spinlock.

The snapshot contains try #3 on getting the locking right.  I had to scrap
my approach after Corinna politely reminded me that I had done something
stupid in the prior snapshot.

But, the spinlock approach was nothing new.  We use that technique in
several places in Cygwin.

cgf

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

