[Info-vax] K-mutex
Pierre
pierre.bru at gmail.com
Wed Dec 14 10:04:01 EST 2011
hi,
about 2 years ago, I was looking for a way to have a k-mutex lock for
one of my programs.
http://groups.google.com/group/comp.os.vms/browse_thread/thread/3e9dd3e88ac04e68
I just realized that I never posted the solution I ended with.
based on Peter Weaver's post, I did the following:
when a process want to use 1 of the K slots for a resource,
1 - get a NL lock on the resource (sys$enqw)
2 - get an EX lock on sub-resource #K (sys$enqw)
3 - if K>1, ask for an EX lock on sub-resource #K-1 with a completion
AST (sys$enq)
when the the completion AST for sub-resource #n-1 fires,
1 - dequeue EX lock for sub-resource #n
2 - if n-2>0, ask for an EX lock on sub-resource #n-2 with the same
completion AST (sys$enq)
when the process is done with the resource,
1 - dequeue all locks on sub-resources
2 - dequeue the NL lock on the resource
the dequeue stuff need to be a bit reworked if the same process wants
to use multiple slots of the same resource.
I didn't use "level 1" resources instead of a master lock/sublocks but
this would have forced the DLM to check the resource-diretory too many
times.
FWIW
More information about the Info-vax
mailing list