Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Dec 2005 08:17:42 -0800
From:      rookie <asmrookie@gmail.com>
To:        John Baldwin <jhb@freebsd.org>
Cc:        freebsd-smp@freebsd.org
Subject:   Re: Use turnstile to implement sx_lock
Message-ID:  <3bbf2fe10512150817s346d621do@mail.gmail.com>
In-Reply-To: <200512151017.12168.jhb@freebsd.org>
References:  <1fa17f810512150652h5da6a6a5g3347f841a614689e@mail.gmail.com> <200512151017.12168.jhb@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
2005/12/15, John Baldwin <jhb@freebsd.org>:
>
> 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 rwlo=
ck
> project.  I've sort-of started on this but haven't gotten very far at all=
 in
> my jhb_lock p4 branch.

I'm working on the same problem too and I found another solution
beacause, in order to mantain a clean design, maybe modifying
turnstiles code is not the better idea.
If we have a thread trying to slock it just blocks if sx is held in
"exclusive mode" by another thread so it's enough a simple turnstile
as for other blocking locks and we have nice priorty propagation. The
real problem is when we try to xlock. A xlocking thread blocks if sx
is held in "shared mode" (even by different owners) so we might
mantain a track of every slocking thread (through a tailqueue, a
static array or whatever) in order to have a priority propagation for
those. I think (I didn't implement yet) it can be done outside the
turnstile context so it seems we don't necessary need to modify.
Finally, we might consider one thing: turnstile has just one owner
while we have (in the slocks) more than one and so what's the real
owner?
We could use a "head thread" per track which must be treacted
carefully (EG: on slocking it we might switch the turnstile owner).

What do you think about?

Attilio

--
Peace can only be achieved by understanding - A. Einstein



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3bbf2fe10512150817s346d621do>