This is the mail archive of the
cygwin-developers@cygwin.com
mailing list for the Cygwin project.
Re: spinlock class?
- From: Joe Buehler <jbuehler at hekimian dot com>
- To: cygwin-developers at cygwin dot com
- Date: Mon, 28 Apr 2003 16:24:36 -0400
- Subject: Re: spinlock class?
- Organization: Spirent Communications, Inc.
- References: <3EAD3E9D.9060504@hekimian.com> <20030428151518.GF30783@redhat.com>
- Reply-to: jbuehler at hekimian dot com
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