Re: recursive mutexes

From: David Schwartz (davids_at_webmaster.com)
Date: 05/15/05


Date: Sun, 15 May 2005 03:13:43 -0700


"Uenal Mutlu" <520001085531-0001@t-online.de> wrote in message
news:d66ogb$2fe$00$1@news.t-online.com...

> C and E are redundant, however application code (the current thread)
> cannot always know that it alread has the lock, though it could test for
> it.

    Yes, it can and must know that it already has the lock. A function that
operates on X should be defined as being called with X locked, or with X
unlocked. It could even take a boolean that indicates whether the caller has
locked the object or not, though this is rarely the right thing to do.

    Simply put, the only thing recursive mutexes gives you is the ability to
write code that deals with X that can be called whether or not X is locked.
This is not only almost never useful, but it's almost always dangerous.

    DS



Relevant Pages

  • Re: Buggy IPI and MTRR code on low memory
    ... We could have a separate lock for each destination ... Then the caller could release the lock. ... because it a) makes the caller hang around until the consumer has ... executed and it b) requires that callers still have local interrupts ...
    (Linux-Kernel)
  • Re: [PATCH 2/3] work_on_cpu: Use our own workqueue.
    ... the caller of flush_workcan detach the work item ... If the caller holds some lock, and if one of the queued work happens ... barrier queued by concurrent flush_work, ... against CPU hotplug), CPU may go away. ...
    (Linux-Kernel)
  • Re: slideshow and variable name for images (global?)
    ... > lock = false; ... boolean value without a specific reason. ... with type-converting comparison are: boolean true, ...
    (comp.lang.javascript)
  • Re: [PATCH 2/3] work_on_cpu: Use our own workqueue.
    ... If the caller holds some lock, and if one of the queued work happens ... barrier queued by concurrent flush_work, ... against CPU hotplug), CPU may go away. ...
    (Linux-Kernel)
  • Re: Should I Be Concerned?
    ... would lock you out temporarily if you failed 4 attempts in a row. ... Unknown user name or bad password ... Caller User Name: ... Source Network Address: ...
    (microsoft.public.windows.server.sbs)