Re: WaitForSingleObject() will not deadlock



On Mon, 02 Jul 2007 01:37:50 -0400 Joseph M. Newcomer <newcomer@xxxxxxxxxxxx> wrote:
I was not aware that anyone would design a non-recursive mutex,
since this has been an integral part of lock design for at least 20
years, if not longer.

I haven't known our good friend the mutex for so long, but I would
hazard a guess that posix mutexes have ALWAYS had recursion as
an option. Because posix has a non-recursive mutex (by default)
doesn't mean it hasn't also always had a recursive mutex.

I was using recursive-acquisition locks in the late 1980s and they
were a well-known technology at the time I was using them. A
non-recursive mutex is not usable for doing things like traversing
circular lists trying to detect circularity, for example.

Sure it is, use trylock() instead of lock().

-frank
.



Relevant Pages

  • Re: Emulating PTHREAD_MUTEX_RECURSIVE - recursive mutex implementation...
    ... turned out to be non-recursive mutex deadlock - and that was not the ... found non-recursive mutex to lead to more complex code in general. ... In my memory allocator, there is a possibility to get memory profile ...
    (comp.programming.threads)
  • Re: WaitForSingleObject() will not deadlock
    ... is-visited bit if the mutex can be queried for the lock count. ... Because, as I stated, a lock count of>1 proves previous visitation. ... not by actually detecting the cycle. ... which is unnecessary with a recursive mutex. ...
    (microsoft.public.vc.mfc)
  • Re: Emulating PTHREAD_MUTEX_RECURSIVE - recursive mutex implementation...
    ... the problems with mine solution first? ... turned out to be non-recursive mutex deadlock - and that was not the ... found non-recursive mutex to lead to more complex code in general. ...
    (comp.programming.threads)
  • Re: WaitForSingleObject() will not deadlock
    ... acquired the first lock cannot acquire a lock either. ... I haven't known our good friend the mutex for so long, ... doesn't mean it hasn't also always had a recursive mutex. ... circular lists trying to detect circularity, ...
    (microsoft.public.vc.mfc)
  • Re: WaitForSingleObject() will not deadlock
    ... CPU clock cycles, right? ... so far this is a standard non-recursive mutex ... Note also that whereas the recursive mutex must maintain a refcount ...
    (microsoft.public.vc.mfc)