pthreads : pthread_cond_signal() from within critical section
I have the following piece of code in thread A, which blocks using pthread_cond_wait() pthread_mutex_lock(&my_lock); if ( false == testCondition ) pthread_cond_wait(&my_wait,&my_lock); pthread_mutex_unlock(&my_lock); I have the following piece of code in thread B, which signals thread A pthread_mutex_lock(&my_lock); testCondition = true; pthread_cond_signal(&my_wait); pthread_mutex_unlock(&my_lock); Provided there are no other threads, would it make any difference if pthread_cond_signal(&my_wait) is moved out of the critical section block as shown below ? pthread_mutex_lock(&my_lock);