windowsmutexcondition-variablerecursive-mutex

Recursive mutex on Windows?


As far as I understand, on Windows CRITICAL_SECTION can be used only as a non-recursive mutex. To get recursive mutex you have to use OpenMutex and friends.

However, AFAIU, Win32 Mutex cannot be used with condition variable (InitializeConditionVariable et al.)

Is there a way to use recursive mutex in conjunction with condition variable on Windows?


Solution

  • valdo's comment is right. CRITICAL_SECTION is recursive. Here's a quotation from MSDN: "After a thread has ownership of a critical section, it can make additional calls to EnterCriticalSection or TryEnterCriticalSection without blocking its execution." Problem solved.