Section: Kernel Functions (9)
sleep_on - synchronization using a condition variable
void sleep_on(struct wait_queue**condition)
function provides a means for synchronizing between processes and
with interrupt handlers. The
parameter is a pointer to a pointer to the opaque wait_queue
type. Initialize the condition variable to zero, then pass a pointer
to it to the
function. The basic idea is as follows:
struct wait_queue*con = 0;
While a process is sleeping, it is fully interruptible, no matter what
the cpu state when entering the function. The cpu state is restored on
If a null(0) is passed to
it returns immediately, without sleeping. This is a no-op.
function only returns when explicitly awakened.
Stephen Williams <email@example.com>
A call to
seems like an interesting way to test for and momentarily allow
interrupts, but that is not what happens.
function cannot be called by interrupt handlers.
The function is not atomic with the condition tests that the driver
writer might include, so the code executing the
function is protected from interrupts. Failure to do so generally
leads to race conditions.