spinlock class?

Christopher Faylor cgf@redhat.com
Mon Apr 28 20:26:00 GMT 2003


On Mon, Apr 28, 2003 at 04:24:36PM -0400, Joe Buehler wrote:
>Christopher Faylor wrote:
>
>>You mean critical sections, maybe?  Although cygwin uses "spinlocks" in
>>one or two cases, they are only for edge cases that should be hit rarely.
>>They're basically a 'if (!test) Sleep (0)'.
>
>OK.  Here's what I ended up doing:
>
>	void lock() {
>		while (InterlockedExchange (&the_lock, 1)) {
>			low_priority_sleep (0);
>		}
>	}
>
>	void unlock() {
>		InterlockedExchange (&the_lock, 0);
>	}

But why not just use a critical section?  It's roughly the same thing,
isn't it?

cgf



More information about the Cygwin-developers mailing list