liveBook · Manning

Cnd_signal

As explained in Modern C

cnd_signal is a C11 condition-variable function that wakes one thread waiting on a condition variable.

cnd_signal is a C11 condition-variable operation that wakes one thread waiting on the supplied condition variable. The awakened thread returns from cnd_wait or cnd_timedwait and must recheck its condition expression. section 18.5

Signaling the next worker

After the account thread performs its work, it calls cnd_signal(&L->upda), notifying the update thread. The update thread similarly signals &L->acco and &L->draw after updating shared state. Each waiter remains inside a mutex-protected while loop, so wake-up does not replace checking whether work is actually available.

How Modern C covers it

How deep it goes
Explains single-waiter wake-up and guarded rechecking, while deferring broader condition-variable implementation details.
Examples
Uses account, update, and draw threads that signal one another after protected work completes.
What it assumes
Assumes condition variables, mutex locking, waiting calls, and shared condition expressions.
What you can do after
Apply via cnd_signal to notify one condition-variable waiter while preserving a loop that validates the shared condition.
How it connects
Connects condition variables with cnd_wait, cnd_timedwait, cnd_broadcast, mutexes, and condition expressions.

Also explained in

Compare how 2 books explain cnd_signal →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C. The section links point to the parts of the book it draws on.