cnd_broadcast is a C condition-variable operation that wakes every thread currently waiting on the corresponding condition variable. The awakened threads return from cnd_wait or cnd_timedwait, reacquire the associated mutex, and must check the condition again before proceeding. section 20.5 section 21.2
Use cnd_broadcast with the same coordination rules as other condition-variable notifications:
- Protect the shared state forming the condition expression with the mutex used by the waiters. section 20.5 section 21.2
- Place the notification inside a critical section protected by that mutex when non-atomic shared data changes. section 21.2
- Keep each wait inside a loop that tests both the condition and any termination state, because a wait can return before the condition is satisfied. section 20.5
Wake all waiters, then recheck
A waiter may use a loop such as while (!L->finished && (L->iteration <= L->drawn)) life_wait(&L->draw, &L->mtx);. A cnd_broadcast(&L->draw) notification wakes every thread waiting on L->draw, but each thread still reacquires L->mtx and evaluates the loop condition before accessing shared state. section 20.5 section 21.2
int cnd_wait(cnd_t*, mtx_t*); int cnd_timedwait(cnd_t*restrict, mtx_t*restrict, const struct timespec *restrict); int cnd_signal(cnd_t*); int cnd_broadcast(cnd_t*);
The condition-variable API listing places cnd_broadcast beside cnd_wait, cnd_timedwait, and cnd_signal, clarifying its role as the wake-all notification operation. section 20.5

