spinlock class?

Joe Buehler jbuehler@hekimian.com
Mon Apr 28 20:24:00 GMT 2003


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);
	}
-- 
Joe Buehler



More information about the Cygwin-developers mailing list