Subj : Re: Deadlock theorem To : comp.programming.threads From : Uenal Mutlu Date : Tue May 03 2005 01:09 am "David Schwartz" wrote > > "Uenal Mutlu" wrote > > Now you say: > > > Of course you are right. I'm aware of the deadlock when there > > is more than 1 thread. The purpose of the code was just to > > show one of the differences between the definition of hierarchical > > locking and my method. > > But before you write: > > > Theorem: > > a) "There will be no deadlock if the objects are locked in the same > > order." > > b) "Unlocking can be done in any order." > > So now I'm totally baffled. Wasn't the point of your theorem to > guarantee that there could never be any deadlocks? The theorem works. The example you are referring to was a (theoretical) example where the following happens inside a single thread: o1.Lock(); o2.Lock(); o3.Lock(); o1.Unlock() o2.Unlock(); o1.Lock(); The reason was just to show that the methods (mine vs. hierarhical locking) are really different at least in such a case. Ie. in my method the o3 lock does not need to be unlocked before being able to lock o1 again, whereas in hierarchical locking it is necessary to unlock all objects deeper in the hierarchy. .