What happens if no threads are waiting and a status signal is sent?

What happens if all threads are busy and the main thread has sent a flow loop signal?

1 main thread and 3 pthreads in thread pool. 3 pthreads are in status

    pthread_mutex_lock(&sync_mutex);
    pthread_cond_wait(&sync_cond, &sync_mutex);
    pthread_mutex_unlock(&sync_mutex);

      

The main thread sent Signal to wake up threads to process the work. In this situation, if 3 threads are already busy and the next signal appears?

+2


source to share


2 answers


Nothing. The signal disappears.



+7


source


If you are using one of the following features:

pthread_cond_signal

- restarts one of the threads waiting for the variable condition cond. pthread_cond_broadcast

- wake up all threads blocked by the specified condition variable.



The manual states that

The pthread_cond_broadcast () and pthread_cond_signal () functions will have no effect if no cond threads are currently blocked.

+4


source







All Articles