Re: WaitForSingleObject() will not deadlock

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Well, you should not care. As long as you acquired the mutex (first or
second time), it's yours. If it's not yours, you're just waiting for that.


"Frank Cusack" <fcusack@xxxxxxxxxxx> wrote in message
news:m2zm2e3a6v.fsf@xxxxxxxxxxxxxxxxxx
Neither does a recursive mutex since a thread other than the one that
acquired the first lock cannot acquire a lock either.
-frank

On Mon, 02 Jul 2007 10:47:10 -0400 Joseph M. Newcomer
<newcomer@xxxxxxxxxxxx> wrote:
No, trylock and its equivalents only say that the object is locked.
It does not guarantee that you can lock an object and examine it, so
it won't do the job of walking a circular structure when there are
potentially concurrent walkers.
joe



.



Relevant Pages

  • Re: [newbie] conditions: signal sent before waiter available?
    ... With a condition variable is a mutex associated. ... In the book, some examples demonstrate condition variables, waiting for signals, sending signals and awakening. ... So the usuale pattern to wait for a predicate is to lock the mutex that synchronize the access to the predicate and than check if that predicate is true. ...
    (comp.programming.threads)
  • Re: pthread_mutex_unlock (was Re: sched_yield() makes OpenLDAP slow)
    ... >>> But why does A take the mutex in the first place? ... >> to take a lock that is incompatible with the lock already being held, ... But you can't know if a higher or lower priority process is waiting. ...
    (Linux-Kernel)
  • Re: How can I make an efficient First-Come-First-Serve locking mechani
    ... "Threads that are waiting for ownership of a mutex are placed in a first in, ... > I have considered using a waitHandle, Monitor, or a C# lock statement ... Who will acquire the lock next? ...
    (microsoft.public.dotnet.general)
  • Re: pthread_mutex_unlock SuS interpretation question
    ... > If -by definition of the OP- threads are waiting for the mutex why ... > should it be allowed that the unlocking thread gets "in front of the ... If the releasing thread needs to lock the ...
    (comp.programming.threads)
  • Re: Recursive mutex that can be waited upon (pthread)
    ... While you can use a mutex to avoid that data is changed, for me having a mutex does not mean that data is not changed, it only means that data is not changed by a different thread. ... My own thread may of course change the data, hence functions I call may want to change the data and if they do so, they must be sure that these changes are atomically, hence they must lock the object and they simply can't rely that I locked the object before -> thus I need recursive locks. ... Then I could as well throw out threads of my code and just use a single thread going through an event queue. ... you have a predicate condition on an invariant. ...
    (comp.programming.threads)