Re: <asm/spinlock.h> issues

Mark Jefferys (mjeffery@cse.ogi.edu)
Tue, 26 Jan 1999 12:02:50 -0800


On Thu, Jan 21, 1999 at 08:15:48AM +0100, Ulrich Windl wrote:

% But another thing came into my mind: In theory it seems a good idea
% to have upgradable and downgradable spinlocks:
%
% Upgrade: Change from read lock to write lock without loosing it
% temporarily
%
% Downgrade: Change from write lock to read lock

% The advantages I see: more concurrency. I don't see additionaly
% dangers of deadlocks here. (But I can be wrong)

If two threads holding a read lock both try to upgrade to a write lock,
they both deadlock.

Downgrading (without losing the lock) is safe, however.

It is possible to add a special read state (X) that can only be held once
at a time, and is (like normal read) incompatible with an active write
lock. Transitions between X and W are safe, as is a transition from
either to R.

In other words, the lock can have at most one special guy who is allowed
to transition between the write and read states, while everyone else can
at most hold and release the read state.

Mark

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/