Subj : Re: recursive mutexes To : comp.programming.threads From : Sergei Organov Date : Mon May 16 2005 05:03 pm "Uenal Mutlu" <520001085531-0001@t-online.de> writes: > "Sergei Organov" wrote > > "Uenal Mutlu" [...] > > > To your question regarding the speed of recursive vs. non-recursive > > > locks: True, recursive locking is slower than non-recursive locking. > > > But recursive locking simplifies coding (no need to have a locked and > > > unlocked version of a function) and makes the application safer wrt > > > self-deadlocking. > > > > Yes, it simplifies coding in the sense that it makes it easier to write > > "working" program that is in fact incorrect. Please try to understand > > what others already told you: dead lock could be a good thing as getting > > it early and correct the problem is much better than hiding the problem > > behind recursive locks. > > But you forget No, I didn't. > the fact that recursive locks have the property to not deadlock the > thread. Sure, and that's one thing that is bad about them, -- they don't deadlock where deadlock (or some other indication of failure) is appropriate. Please try to stop answering immediately and think a little bit, 1 to 7 days of thinking seems to be enough to understand that deadlock is not the ultimate and the only enemy in programming and that deadlock could well be programmers friend, -- then come back and tell us something new. > Then it is not valid to say that because I called Lock() twice that > this leads to deadlock, no! Sure, it is not valid, but nobody said that it is. Please *read* what you are replying to, as currently you are replying to your own thoughts, not to what I wrote, and if you need to talk to yourself, there is no reason to use public newsgroup for that. > I'm willingly making use of its recursivity feature because it > simplifies many things, and most importantly it is safer than > non-recursive locking, It depends on the definition of "safer". For me "safer" is not equal to "no deadlock". Using my definition of "safer", the recursive lock is not safer due to the fact that it allows actual problems in the code to be hidden for a long time. > though it has a neglectable overhead. If I use a _recursive locking > method_ then I'm of course aware of these facts. If you were aware of the experience that has been gathered in this field, you won't use recursive locking method in the first place. The recursive locks simplify your life by allowing you not to think about quality of your design. Kinda like favorite goto's in programming languages, -- they do simplify programming in the short run but the result is usually a wrong and unmaintainable problem^H^H^H^Hgram in the long run. If you consider such simplifications to be a good thing, -- it's your problem. -- Sergei. .