Use turnstile to implement sx_lock
rookie
asmrookie at gmail.com
Thu Dec 15 08:17:45 PST 2005
2005/12/15, John Baldwin <jhb at 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 rwlock
> 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
More information about the freebsd-smp
mailing list