Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
SLEEP(9)	       FreeBSD Kernel Developer's Manual	      SLEEP(9)

NAME
     sleep, tsleep, wakeup -- wait for events

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

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

     void
     wakeup(void *ident);

     int
     sleep(void	*ident,	int priority);

DESCRIPTION
     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	iden-
     tifies 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	arbi-
     trary strings, this message should	not be longer than 6 characters.

     Tsleep 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 cur-
     rent system call should be	restarted if possible, and EINTR is returned
     if	the system call	should be interrupted by the signal (return EINTR).

     Sleep is the traditional form.  It	doesn't	let you	specify	a timeout nor
     a wmesg, hence its	use is deprecated.

RETURN VALUES
     See above.

SEE ALSO
     ps(1)

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

     Tsleep appeared in	4.4BSD.

AUTHORS
     This man page has been written by Joerg Wunsch.

FreeBSD	11.1			 April 3, 1996			  FreeBSD 11.1

NAME | SYNOPSIS | DESCRIPTION | RETURN VALUES | SEE ALSO | HISTORY | AUTHORS

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=sleep&sektion=9&manpath=FreeBSD+2.2.1-RELEASE>

home | help