You should always unlock the mutex after calling pthread_cond_signal Here are some good questions/answers to read.
You should always unlock the mutex after calling pthread_cond_signal. Here are some good questions/answers to read: Calling pthread_cond_signal without locking mutex It won't come to me right now, but I'm pretty sure there's a good reason (in terms of race conditions) that you don't want to unlock the mutex before signalling.
– ManRow Mar 3 at 3:45 1 @ManRow: There may be such a guarantee in the Priority Scheduling option, if the right priorities are set. Otherwise, definitely not. – R.. Mar 3 at 3:53 1 The good reason is avoiding priority inversion: groups.google.
Com/group/comp.programming. Threads/msg/… linked from stackoverflow.Com/questions/4544234/… – ninjalj Mar 15 at 23:43.
If you keep the mutex locked, then the thread being woken cannot acquire the mutex, so will block in pthread_cond_wait waiting to reacquire the mutex. You do not need to hold the mutex locked to call pthread_cond_signal. In fact, if your application logic can work with a signal when the mutex is not locked then that is a better way to do it --- the OS can schedule the waiting thread immediately, and it doesn't have to wait for the signalling thread to unlock the mutex before proceeding.
However, in this scenario care must be taken to ensure that the wake-up is not lost, and you don't have a problem with the "wrong" thread being woken. If you use a straight-forward predicate, this shouldn't be a problem in practice.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.