Use turnstile to implement sx_lock

John Baldwin jhb at freebsd.org
Thu Dec 15 07:16:50 PST 2005


On Thursday 15 December 2005 09:52 am, prime wrote:
> hi hackers,
> I want to use turnstile to implement sx_lock( or read/write  lock),but
> find that there is a big obstacle,
> ONE sx_lock needs TWO queues to put waiters on,one for readers and the
> other one for writers,but ONE turnstile can only supply ONE queue,and ONE
> sx_lock can only get ONE turnstile.
>
> I read opensolaris' rw_lock implementation and find that its turnstile
> has TWO queues which is different from FreeBSD's turnstile.
>
> Are there any good ideas to bypass the obstacle? Thanks very much.

You have to add a second queue to the turnstile and make priority propagation 
still work, etc.  Mutexes would just use the exclusive queue all the time 
whereas rwlocks would use both queues.  This is the hard part of the rwlock 
project.  I've sort-of started on this but haven't gotten very far at all in 
my jhb_lock p4 branch.

-- 
John Baldwin <jhb at FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve"  =  http://www.FreeBSD.org


More information about the freebsd-hackers mailing list