Subj : Re: Challenge: Multithreading & Synchronization To : comp.programming.threads From : gottlobfrege Date : Wed May 18 2005 11:20 pm Uenal Mutlu wrote: > > >> // assume all public functions can make calls to each other, > > >> // and also to internal funcs > > >> > > >> void f1(void* Ap = 0) > > >> { // uses vJD, vMD > > >> Locker L1(vJD.m); // the order of the locks is important > > >> Locker L2(vMD.m); > > >> > > >> //... > > >> } > > >> > > >> void f2(void* Ap = 0) > > >> { // uses vMD, vSD > > >> Locker L1(vSD.m); > > >> Locker L2(vMD.m); > > >> > > >> //... > > >> } > > >> > > >> void f3(void* Ap = 0) > > >> { // uses vSD, vMD > > >> Locker L1(vSD.m); > > >> Locker L2(vMD.m); > > >> > > >> //... > > >> } Maybe I'm missing something: thread 1 calls f1, locks JD, MD... thread 2 slips in and calls f2, locks SD, tries to lock MD, but has to wait on thread 1. thread 1 continues, and, based on > > >> // assume all public functions can make calls to each other, let's say f1 calls f3, thus tries to lock SD, but can't because thread 2 has it locked, so waits on thread 2 who is waiting on thread 1... am I missing something? Tony .