Subj : Re: recursive mutexes To : comp.programming.threads From : Uenal Mutlu Date : Mon May 16 2005 08:04 am "David Schwartz" wrote > > I never argued the performance issue. But here's a more realistic > example: The example was in response to Peter's posting who wrote "No, he's in fact making the program faster." 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. And my point is: if the recursive-locking is a fast implementation, then the overhead of recursive locking is minimally (inc and dec). And if this is true (and it is) then why make life complicated by not using them since they have the above positive properties. And, IMO it is not a good design to test in f() whether the object was locked or not. I prefer the following "agreement" or "contract": It is the caller's job to call f() only after having the lock. It is not f()'s job to check whether the object was locked. This too simplies coding, and it leads to faster programs. .