X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=cprogs%2Fwith-lock-ex.1;fp=cprogs%2Fwith-lock-ex.1;h=ce3f87fd1b840f86a584e3727ff18588a5a214d1;hb=78ad6d7c4fcfc77d83649a4082a8dae4359bdbf1;hp=f83f263f1ec3a7cd2b651b8467586c3880bca978;hpb=fe9202c6642da48eec7ebf233e5feddf88cd0e62;p=chiark-utils.git diff --git a/cprogs/with-lock-ex.1 b/cprogs/with-lock-ex.1 index f83f263..ce3f87f 100644 --- a/cprogs/with-lock-ex.1 +++ b/cprogs/with-lock-ex.1 @@ -56,6 +56,30 @@ which a process might lock simultaneously, either or .IR B > A where the relation > is transitive and noncyclic. +.PP +Then, for any two locks +.I X +and +.I Y +with +.IR X > Y +it is forbidden to acquire +.I X +while holding +.IR Y . +Instead, acquire +.I X +first, or release +.I Y +before (re)acquiring +.I X +and +.I Y +in that order. +.PP +(There are more complicated ways of avoiding deadlocks, but a lock +hierarchy is simple to understand and implement. If it does not meet +your needs, consult the literature.) .SH LOCKING PROTOCOL The locking protocol used by .B with-lock-ex