wakeup man page on MirBSD

Man page or keyword search:  
man Server   6113 pages
apropos Keyword Search (all sections)
Output format
MirBSD logo
[printable version]

SLEEP(9)		      BSD Kernel Manual			      SLEEP(9)

NAME
     sleep, tsleep, wakeup - process context sleep and wakeup

SYNOPSIS
     #include <sys/types.h>
     #include <sys/proc.h>

     int
     tsleep(void *ident, int priority, const char *wmesg, int timo);

     void
     sleep(void *ident, int priority);

     void
     wakeup(void *ident);

DESCRIPTION
     These functions implement voluntary context switching. tsleep() and
     sleep() are used throughout the kernel whenever processing in the current
     context can not continue for any of the following reasons:

	   +   The current process needs to await the results of a pending I/O
	       operation.

	   +   The current process needs resources (e.g., memory) which are
	       temporarily unavailable.

	   +   The current process wants access to data structures which are
	       locked by other processes.

     The function wakeup() is used to notify sleeping processes of possible
     changes to the condition that caused them to go to sleep. Typically, an
     awakened process will -- after it has acquired a context again -- retry
     the action that blocked its operation to see if the "blocking" condition
     has cleared.

     The bpendsleep label can be used as a break-point to debug a process com-
     ing back from tsleep().

     The tsleep() function takes the following arguments:

     ident     An identifier of the "wait channel" representing the resource
	       for which the current process needs to wait. This typically is
	       the virtual address of some kernel data structure related to
	       the resource for which the process is contending. The same
	       identifier must be used in a call to wakeup() to get the pro-
	       cess going again. ident should not be NULL.

     priority  The process priority to be used when the process is awakened
	       and put on the queue of runnable processes. This mechanism is
	       used to optimize "throughput" of processes executing in kernel
	       mode. If the flag PCATCH is OR'ed into priority the process
	       checks for posted signals before and after sleeping.

     wmesg     A pointer to a character string indicating the reason a process
	       is sleeping. The kernel does not use the string, but makes it
	       available (through the process structure field p_wmesg) for
	       user level utilities such as ps(1).

     timo      If non-zero, the process will sleep for at most timo/hz
	       seconds. If this amount of time elapses and no wakeup(ident)
	       has occurred, and no signal (if PCATCH was set) was posted,
	       tsleep() will return EWOULDBLOCK.

     The sleep() function puts the process in an uninterruptible sleep. It is
     functionally equivalent to:

	   tsleep(ident, priority & PRIMASK, 0, 0)

     The wakeup() function will mark all processes which are currently sleep-
     ing on the identifier ident as runnable. Eventually, each of the
     processes will resume execution in the kernel context, causing a return
     from [t]sleep(). Note that processes returning from sleep should always
     re-evaluate the conditions that blocked them, since a call to wakeup()
     merely signals a possible change to the blocking conditions. For example,
     when two or more processes are waiting for an exclusive lock, only one of
     them will succeed in acquiring the lock when it is released. All others
     will have to go back to sleep and wait for the next opportunity.

RETURN VALUES
     tsleep() returns 0 if it returns as a result of a wakeup(). If a tsleep()
     returns as a result of a signal, the return value is ERESTART if the sig-
     nal has the SA_RESTART property (see sigaction(2)), and EINTR otherwise.
     If tsleep() returns as a result of a timeout, the return value is
     EWOULDBLOCK.

CODE REFERENCES
     These functions are implemented in the file sys/kern/kern_synch.c.

SEE ALSO
     hz(9), mi_switch(9), timeout(9)

MirOS BSD #10-current		June 23, 1996				     1
[top]

List of man pages available for MirBSD

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net