From: ianmdlvl Date: Sun, 13 Jul 2003 22:51:47 +0000 (+0000) Subject: improve deadlock section X-Git-Tag: rel-4-0-0~2 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=commitdiff_plain;h=78ad6d7c4fcfc77d83649a4082a8dae4359bdbf1 improve deadlock section --- 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