12-17-04 12:45 AM
Hello
i have such code in one thread1:
pthread_mutex_lock(m)
if (something)
pthread_cond_signal(c)
pthread_mutex_unlock(m)
and in thread2:
pthread_mutex_lock(m)
if (something2)
pthread_cond_wait(c,m)
pthread_mutex_unlock(m)
Thread2 wait on pthread_cond_wait(), and after that Thread1 calls
pthread_cond_signal(). I am not sure what is next. Does:
in this moment thread1 calls pthread_mutex_unlock(m), and after that
thread2 receives mutex m, and then unlock it and finishes ?
So in such case Thread2 does not start immediately after receiving
signal on conditional value, because it must wait for mutex, am i right ?
Thanx
Michal
[ Post a follow-up to this message ]
|