![]() |
![]() |
![]() |
Unblock waiting threads
#include <pthread.h> int pthread_sleepon_broadcast( const volatile void * addr );
libc
The pthread_sleepon_broadcast() function unblocks all threads currently waiting on addr. The threads are unblocked in priority order.
Here's a table to help you decide when to use pthread_sleepon_broadcast() or pthread_sleepon_signal():
Task | pthread_sleepon_broadcast() | pthread_sleepon_signal() |
---|---|---|
Mapping a single predicate to one address. | You must recheck the predicate and reblock if necessary.
See pthread_sleepon_signal() for a better
implementation.
The first thread to wake up owns the lock, all others must go back to sleep. |
This is the correct and efficient use of
pthread_sleepon_signal(). You don't have to recheck
the predicate.
One thread owns the lock at a time. |
Mapping multiple predicates to one address. | The pthread_sleepon_broadcast() function is necessary to wake up
all blocked threads. You must recheck the predicates and
reblock if necessary.
You should try to map only one predicate to one address. |
Don't use pthread_sleepon_signal() in this case; it could result in a deadlock. |
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
pthread_cond_broadcast(), pthread_sleepon_signal(), pthread_sleepon_lock(), pthread_sleepon_unlock(), pthread_sleepon_wait()
![]() |
![]() |
![]() |