445 Subj : Re: Deadlock theorem To : comp.programming.threads From : Peter Koch Larsen Date : Mon May 02 2005 02:40 pm "Uenal Mutlu" <520001085531-0001@t-online.de> skrev i en meddelelse news:d548ah$j2u$05$1@news.t-online.com... > "Joe Seigh" wrote >> >> Releasing a lock doesn't block, so there's no requirement on any >> release order, though you can't reacquire the lock if you hold locks >> further down in the hierarchy without releasing those locks first. > > Do you mean that the following case is not possible with hierarchical > locking? > o1.Lock(); > o2.Lock(); > o3.Lock(); > o1.Unlock() > o2.Unlock(); > o1.Lock(); > > With my method this is possible. And this also shows that the > methods indeed aren't the same. > > What do you mean? Let us test your solution: Thread 1: o1.Lock(); o2.Lock(); o3.Lock(); o1.Unlock() o2.Unlock(); >> context switch Thread 2: o1.Lock(); o2.Lock(); o3.Lock(); => waits for unlock by thread 1 Thread 1 resumes: o1.Lock(); => waits for unlock by thread 2 A nice and simple deadlock. /Peter . 0