sleep_on - synchronization using a condition variable
void sleep_on(struct wait_queue**condition))
The sleep_on function provides a means for synchronizing
between processes and with interrupt handlers. The condition
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 sleep_on function. The basic idea is as
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 being awakened.
If a null(0) is passed to sleep_on, it returns immediately,
without sleeping. This is a no-op.
The sleep_on function only returns when explicitly awakened.
Stephen Williams <firstname.lastname@example.org>
A call to sleep_on(0) seems like an interesting way to test
for and momentarily allow interrupts, but that is not what
The sleep_on function cannot be called by interrupt
The function is not atomic with the condition tests that the
driver writer might include, so the code executing the
sleep_on function is protected from interrupts. Failure to
do so generally leads to race