The question is when there are more than one threads waiting on a
pthread_mutex_lock() and if the owner of the mutex unlocks it which
thread will get to lock the mutex, assuming that all threads are of
The Reason for the question is the following passage from "pthreads
programming O'Reilly & associates "...
Appendix C :Pthreads quick reference Page 258
Unlocks a mutex. The scheduling priority determines which blocked
thread is resumed. The resumed thread may not succeed in it s next
attempt to lock the mutex, depending upon whether another thread has
locked the mutex in the interval between the thread's being resumed and
it s issuing the pthread_mutex_lock() call."
Does this mean that thread A was resumed but another thread ( say B )
got the mutex. I agree I m not very clear about the word "resume". Is
this to mean that the woken up thread will enter some rigorous polling
till it can get the mutex. It sounds like some kind of signalling
between the unlocker and the waiters - like the case of
pthread_cond_signal(). If there was some kind of signalling, can that
be sent to more than one waiting threads. If it can be sent to only one
thread, how can the above condition arise at all, since only one thread
will be woken up which will succeed in locking the mutex. Or is the
Any clarification will be greatly appreciated.
Sent via Deja.com http://www.deja.com/
Before you buy.