Unblock waiting threads
#include <pthread.h> int pthread_sleepon_broadcast( const volatile void * addr );
- The handle that the threads are waiting on. The value of addr is typically a data structure that controls a resource.
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The pthread_sleepon_broadcast() function unblocks all threads currently waiting on addr. The threads are unblocked in priority order.
You should use pthread_sleepon_broadcast() or pthread_sleepon_signal(), depending on the task you're doing:
- Mapping a single predicate to one address
- Use pthread_sleepon_signal().
If you use pthread_sleepon_broadcast(), you must recheck the predicate and reblock if necessary. The first thread to wake up owns the lock; all others must go back to sleep.
If you use 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
- You need to use pthread_sleepon_broadcast() 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.
- Invalid sleepon address.
Last modified: 2014-06-24