From 78ad6d7c4fcfc77d83649a4082a8dae4359bdbf1 Mon Sep 17 00:00:00 2001 From: ianmdlvl Date: Sun, 13 Jul 2003 22:51:47 +0000 Subject: [PATCH] improve deadlock section --- cprogs/with-lock-ex.1 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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 -- 2.30.2