[Info-vax] counting-lock ?

Pierre pierre.bru at gmail.com
Sun Oct 25 14:49:01 EDT 2009


On Oct 25, 5:07 am, moro... at world.std.spaamtrap.com (Michael Moroney)
wrote:

> I think I have an algorithm that needs fleshing out.  You have a master
> lock M as well as other locks, numbered 1 through n-1 (n=5 in this case).
> A process tries to get the master lock in exclusive mode, waiting until it
> can.  If it's waiting it normally means there are n processes running
> already, but can also be transient.  If it gets the lock, it counts the
> number of holders.  If it's less than n, it converts the master lock to
> null mode, and gets an exclusive lock on one of the numbered locks.  
> (this part needs work, but for now, assume it tries Lock 1 first, if it
> can't get it immediately, it tries Lock 2, then lock 3 etc), then converts
> the master lock to Null, allowing another process to get it.  If the
> number of holders on the master lock = n, it does _not_ convert the lock
> (thus blocking the next process) but instead requests access to all the
> numbered locks. As long as the other processes hold these locks, the
> process holding the master lock won't get any of them.  Once any of these
> other processes exits, releasing one of the numbered locks, the process
> holding the master lock in EX has that numbered lock, and converts the
> master lock to NULL, allowing another process to run.

your algorithm resemble mine but is easier to implement :) keeping the
EX lock on the master lock make the life easier than converting it to
NL after enqueing EX lock on numbered ones. and as other processes
wanting to access the "multi-resource" are waiting behind the master
lock and not behind the numbered locks, the DLM has less job to do.

Pierre.



More information about the Info-vax mailing list