[PATCH] Adding Solaris-style "owner of records" to rwlocks

Attilio Rao attilio at freebsd.org
Mon Aug 14 19:01:01 UTC 2006

2006/8/7, Attilio Rao <attilio at freebsd.org>:
> This is a first implementation of the owner of records concept in rwlocks.
> It allows to avoid the priority inversion problem in the current
> rwlocks implementation (for readers).
> The main idea (that John and I discussed) is to have as owner of
> records the first rlock'er for a "class contention".
> The implementation consists in adding two flags (RW_LOCK_OWNED and
> RW_LOCK_EXEMPTED) which are used in order to not penalyze the easy
> case, and syncronizing the operation of acquiring and dropping the
> owner of records with the turnstile spin-lock.
> The main scheme might work in this way:
> thread1::rlock() -> sets the owner of records
> thread2::rlock() -> checks for RW_LOCK_OWNED bit and, if it is set, go
> in the easy case
> thread3::rlock() -> checks for RW_LOCK_OWNED...
> thread4::wlock() -> blocks and land its priority to thread1
> thread1::runlock() -> disable the owner of records (disowning the
> associated turnstile) and sets the RW_LOCK_EXEMPTED flag. In this way
> other threads will treact as an easy case.
> ...
> What I actually need is a testing suite for heavy-load contentions,
> since I would like to detect eventual races I missed, etc. If somebody
> has a get-ready testing suite, please, let me know.
> The patch against HEAD is here:
> http://users.gufi.org/~rookie/works/patches/rwlocks.diff
> Please, this is not intended to be a final implementation for this,
> since I think that it can be improved; it is just a starting point for
> ongoing works and improvements.

I cleaned a lot the code, added some extra debug stubs and comments
and get rid of RW_LOCK_EXEMPTED bit.

Please refer to:

in order to make tests and comments.


Peace can only be achieved by understanding - A. Einstein

More information about the freebsd-current mailing list