Subject: Re: Lock benchmarks
To: None <email@example.com>
From: Jason R Thorpe <firstname.lastname@example.org>
Date: 09/18/2002 15:26:03
On Thu, Sep 19, 2002 at 08:33:18AM +1200, Gregory McGarry wrote:
> > 1. In a RAS locking scheme, you only ever want to provide
> > or use the "lock_try" version. This is because if the
> > lock is held, know either: (a) you need to context
> > switch, (b) you need to croak (deadlock). If you spin
> > around, then you're just consuming cpu time, and might
> > deadlock if your threads aren't being timesliced against
> > each other.
> Yep. And the pthread library currently works like that.
My point was that you don't need to provide the looping version of
__ras_simple_lock(), only __ras_simple_lock_try().
...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.
-- Jason R. Thorpe <email@example.com>