endtsleep, sleepinit, unsleep -- manage the queues of sleeping processes
#include <sys/param.h>
#include <sys/proc.h>
void
endtsleep(void *arg);
void
sleepinit(void);
void
unsleep(struct thread *td);
The sleep queues used by msleep(9) and friends are stored in a hash
array. The address of the wait channel is used to generate an index into
the array. Each entry in the array is a queue of processes that are
sleeping on wait channels that hash to that index. msleep(9) places processes
into their appropriate queues directly. To handle timeouts, the
endtsleep() function is registered as a timeout(9). When the process is
woken by either wakeup() or wakeup_one(), the timeout is revoked via
untimeout(9). If the process is not awakened soon enough, then
endtsleep() is called with arg pointing to the struct proc of the process
that timed out. endtsleep() undoes the sleep and makes the process
runnable if it is in the SSLEEP state. The sleep queues and the hash
array are protected internally by the sched_lock mutex.
unsleep() simply removes the thread td from its sleep queue.
sleepinit() is called during system startup and initializes the scheduler
quantum (sched_quantum) and the sleep queues.
msleep(9), runqueue(9), scheduler(9)
FreeBSD 5.2.1 November 3, 2000 FreeBSD 5.2.1 [ Back ] |