Subject: Re: Lock benchmarks
To: Jason R Thorpe <>
From: Nathan J. Williams <>
List: tech-kern
Date: 09/18/2002 18:31:59
Jason R Thorpe <> writes:

> ...and, actually, there is one place where __cpu_simple_lock() is used
> in libpthread: pthread_spin_lock().
> That function should be changed to use a loop around __cpu_simple_lock_try()
> and detect deadlock and return the EDEADLK error.


The pthread_spin_lock() function is specified as a "you are likely to
lose" function. It would be easy to make it loop around
__cpu_simple_lock_try(), but it is under no obligation whatsoever to
detect deadlock (which would anyway only be valid if the *calling
thread* already held the lock).

There's a good reason that the internal spinlock primitives in the
pthread library are different from pthread_spin_lock().

        - Nathan