Subj : Re: Deadlock theorem To : comp.programming.threads From : Uenal Mutlu Date : Tue May 03 2005 08:50 pm "David Holmes" wrote > "Uenal Mutlu" wrote > > Theorem: > > a) "There will be no deadlock if the objects are locked in the same > order." > > b) "Unlocking can be done in any order." .... > deadlock occurs if you have a cyclic dependency in the lock acquisition > order: > - thread 1: acquire A try to acquire B > - thread 2: acquire B try to acquire A > > This is the defining property of deadlock. > > Every text that discusses deadlock discusses the ways to avoid deadlock. > Acquiring your locks in a consistent order is one such technique. Sure, I just tried to formulate a law and to apply it practically, esp. for thread programming. > This solution has been known ever since "locking" (or historically it was > probably described in terms of semaphore operations) has existed. I wonder why they used the term "semaphore operations" whereas "order of locking" would very much suffice. .