chiark / gitweb /
improve deadlock section
authorianmdlvl <ianmdlvl>
Sun, 13 Jul 2003 22:51:47 +0000 (22:51 +0000)
committerianmdlvl <ianmdlvl>
Sun, 13 Jul 2003 22:51:47 +0000 (22:51 +0000)
cprogs/with-lock-ex.1

index f83f263f1ec3a7cd2b651b8467586c3880bca978..ce3f87fd1b840f86a584e3727ff18588a5a214d1 100644 (file)
@@ -56,6 +56,30 @@ which a process might lock simultaneously, either
 or
 .IR B > A
 where the relation > is transitive and noncyclic.
 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
 .SH LOCKING PROTOCOL
 The locking protocol used by
 .B with-lock-ex