*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->FreeBSD man pages -> wakeup (9)              
Title
Content
Arch
Section
 

SLEEP(9)

Contents


NAME    [Toc]    [Back]

     sleep, msleep, tsleep, wakeup -- wait for events

SYNOPSIS    [Toc]    [Back]

     #include <sys/param.h>
     #include <sys/systm.h>
     #include <sys/proc.h>

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

     int
     msleep(void *ident, struct mtx *mtx, int priority, const char *wmesg,
	 int timo);

     void
     wakeup(void *ident);

     void
     wakeup_one(void *ident);

DESCRIPTION    [Toc]    [Back]

     The functions tsleep() and wakeup() handle event-based process blocking.
     If a process must wait for an external event, it is put on sleep by
     tsleep().	The parameter ident is an arbitrary address that uniquely
     identifies the event on which the process is being asleep.  All processes
     sleeping on a single ident are woken up later by wakeup(), often called
     from inside an interrupt routine, to indicate that the resource the
     process was blocking on is available now.

     The parameter wmesg is a string describing the sleep condition for tools
     like ps(1).  Due to the limited space of those programs to display arbitrary
 strings, this message should not be longer than 6 characters.

     The wakeup_one() function is used to make the first process in the queue
     that is sleeping on the parameter ident runnable.	This can prevent the
     system from becoming saturated when a large number of processes are
     sleeping on the same address, but only one of them can actually do any
     useful work when made runnable.

     The tsleep() function is the general sleep call.  Suspends the current
     process until a wakeup is performed on the specified identifier.  The
     process will then be made runnable with the specified priority.  Sleeps
     at most timo / hz seconds (0 means no timeout).  If pri includes the
     PCATCH flag, signals are checked before and after sleeping, else signals
     are not checked.  Returns 0 if awakened, EWOULDBLOCK if the timeout
     expires.  If PCATCH is set and a signal needs to be delivered, ERESTART
     is returned if the current system call should be restarted if possible,
     and EINTR is returned if the system call should be interrupted by the
     signal (return EINTR).

     The msleep() function is a variation on tsleep.  The parameter mtx is a
     mutex which will be released before sleeping and reacquired before
     msleep() returns.	If pri includes the PDROP flag, the mtx parameter will
     not be reacquired before returning.  The mutex is used to ensure that a
     condition can be checked atomically, and that the current process can be
     suspended without missing a change to the condition, or an associated
     wakeup.

RETURN VALUES    [Toc]    [Back]

     See above.

SEE ALSO    [Toc]    [Back]

      
      
     ps(1), malloc(9), mi_switch(9)

HISTORY    [Toc]    [Back]

     The sleep/wakeup process synchronization mechanism is very old.  It
     appeared in a very early version of UNIX.

     The tsleep() function appeared in 4.4BSD.

     The sleep() function used to be the traditional form.  It did not let you
     specify a timeout or a wmesg, hence it was discontinued.

AUTHORS    [Toc]    [Back]

     This man page was written by Jorg Wunsch <[email protected]>.


FreeBSD 5.2.1		       December 17, 1998		 FreeBSD 5.2.1
[ Back ]
 Similar pages
Name OS Title
dooneevent IRIX wait for events and invoke event handlers
evmwatch Tru64 Monitors EVM events
evmviewer Tru64 View events
evmsort Tru64 Sorts events
pthread_cond_timedwait Tru64 Causes a thread to wait for the
pause Linux wait for signal
wstat IRIX wait status
sigsuspend HP-UX wait for a signal
EvmEventFormatFromTemplate Tru64 Format events for display
EvmEventWrite Tru64 Performs I/O of events to and from a file
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service