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_cond_wait(&sync_cond, &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?


source to share

2 answers

Nothing. The signal disappears.



If you are using one of the following features:


- 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.



All Articles