Pthread spin locks
Daniel Eischen
deischen at freebsd.org
Mon Mar 19 21:06:02 UTC 2007
On Mon, 19 Mar 2007, Joerg Sonnenberger wrote:
> On Mon, Mar 19, 2007 at 02:04:58PM -0400, Daniel Eischen wrote:
>> No, especially if the threads hold other locks.
>> I have no idea why POSIX added spinlocks. I don't
>> see why anyone would want to use them.
>
> Given that it is part of the realtime extensions, it makes sense. On
> those systems you generally also have policies for scheduler control
> like CPU affinity, which can make the starvation impossible.
PTHREAD_PRIO_PROTECT and PTHREAD_PRIO_INHERIT
POSIX doesn't seem to have specified APIs for
scheduler affinity and has said that the behavior
of threads in scheduling domains > 1 is implementation
defined. So it is somewhat surprising to me that
spinlocks were added.
It also assumes that the implementation of non-spin mutexes
is inefficient which is not necessarily the case. It is
certainly possible for the implementation to use adaptive
mutexes which spin for a bit before sleeping.
--
DE
More information about the freebsd-hackers
mailing list