Read/write locks

Colin Plumb (colin@nyx.net)
Sat, 20 Sep 1997 21:09:41 -0600 (MDT)


A further improvement to read/write locks that increases parallelism
even further is read/write/update locks. They can be constructed
trivially from a read/write lock and an update semaphore. You may only
contend for the write lock while holding the update semaphore, which
might simplify the read/write lock implementation. (The update
semaphore implicitly grants a read lock, too.)

This is useful for calls like rename that have to verify a lot of
invariants (if renaming dira to dirb, you have to walk upwards from
dirb making sure that you can get to the root without hitting dira or
the rename would create a bad cycle) before actually getting to the
real work.

An update lock lets you read the structure while guaranteeing it will
not change, and also that you can upgrade it to a write lock without
the structure changing.

Wat's interesting is the change here from the optimisitc locking used
earlier to strict locking, when most databases are moving in the
opposite direction in the quest for better parallelism. But it is
indeed harder to write correct optimisitic code.

-- 
	-Colin