spin locks - Mailing list pgsql-hackers

From Bruce Momjian
Subject spin locks
Date
Msg-id 199802150527.AAA15181@candle.pha.pa.us
Whole thread Raw
Responses Re: [HACKERS] spin locks  (The Hermit Hacker <scrappy@hub.org>)
List pgsql-hackers
> spin-lock.patch
>
>     I'm not sure if this is really useful, but it seems stupid to have
>     a backend wasting cpu cycles in a busy loop while the process which
>     should release the lock is waiting for the cpu. So I added a call
>     to process_yield() if the spin lock can't obtained.
>     This has been implemented and tested only on Linux. I don't know if
>     other OS have process_yield(). If someone can check please do it.

Massimo brings up a good point.  Most of our s_lock.h locking does asm
mutex loops looking for a lock.  Unless we are using a multi-cpu
machine, there is no way this is going to change while we are spinning.

Linux has process_yield(), but most OS's don't.  Is there a
platform-independent way to relinquish the cpu if the first attempt at
the spinlock fails?  Would a select() of 1 microsecond work?

--
Bruce Momjian
maillist@candle.pha.pa.us

pgsql-hackers by date:

Previous
From: Brook Milligan
Date:
Subject: Re: [PORTS] Re: [HACKERS] Valid ports for v6.3 -- NetBSD/i386 compile errors
Next
From: The Hermit Hacker
Date:
Subject: Re: [HACKERS] spin locks