From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-07-12 15:51:53
Howard Hinnant wrote:
> On Jul 12, 2004, at 1:35 PM, Peter Dimov wrote:
>>> On the other hand, our Windows implementation of condition::wait
>>> follows the algorithm laid out by Alexander Terekhov's "Algorithm
>>> 8a" posted in comp.programming.threads on April 27, 2001 (and noted
>>> as such in that file Alexander). In this case the wait() function
>>> does not differ depending upon the recursiveness of the mutex.
>> To clarify: does your implementation support waiting on a recursive mutex
>> that has been locked more than once, temporarily decreasing its lock
>> to zero to allow other threads to acquire the mutex while the
>> original thread is blocked by the wait?
> That was the intent. But I stand corrected. I evidently got it wrong
> except on Mac OS X where I do explicitly decrement the count to 0 of
> the pthread_mutex during a wait (recursive mutex case only). Looks
> like I need to dig back into this on other platforms...
Doesn't this impose some overhead on your recursive_mutex, even if the user
never takes advantage of this feature? (I have to admit that I don't have
the slightest idea how is this possible to implement correctly.)