The scenario of my problem:
I have 3 threads with one mutex, one cond and a variable to share with.
The first thread is a controller thread which changes the variable incrementally while the rest two threads will compete against each other for its turn to read this variable. The purpose for this setup is so that the two working threads have a unique number after doing a read. For the controller thread, wait() will be called after changing the variable.
Assuming worker thread 1 wins the competition for resource and completes its read, calls signal() and releases the mutex, will the controller thread automatically awakes and locks the mutex?? or will it have to compete with thread 2 for this mutex after awakening??
Any help is appreciated.