4e2 Subj : Re: recursive mutexes To : comp.programming.threads,comp.unix.programmer From : Torsten Robitzki Date : Mon May 16 2005 03:50 pm Uenal Mutlu wrote: > "David Schwartz" wrote > >>"Uenal Mutlu" wrote >> >> Yes, it can and must know that it already has the lock. A function that >>operates on X should be defined as being called with X locked, or with X >>unlocked. It could even take a boolean that indicates whether the caller has >>locked the object or not, though this is rarely the right thing to do. > > > You are unnecessarily complicating things and make the program > slower by doing these testings. It doesn't really matter if you code this test by yourself or let the recursive lock do this test for you. As this explicit coded flag does not need any synchronization it might even be faster then the necessary test a recursive lock have to do. > These tests are not necessary if > your design is good. Right, and the only way to get rid of this tests is to design the code in such a way that you know for every function if a lock is held of if a lock have to be acquired. regards Torsten P.S. never used recursive locks and never had any serious problems with deadlocks. . 0