xref: /csrg-svn/lib/libc/gen/usleep.3 (revision 48352)
1*48352Scael.\" Copyright (c) 1986, 1991 Regents of the University of California.
2*48352Scael.\" All rights reserved.
325789Smckusick.\"
4*48352Scael.\" %sccs.include.redist.man%
525789Smckusick.\"
6*48352Scael.\"     @(#)usleep.3	6.4 (Berkeley) 04/19/91
7*48352Scael.\"
8*48352Scael.Dd
9*48352Scael.Dt USLEEP 3
10*48352Scael.Os BSD 4.3
11*48352Scael.Sh NAME
12*48352Scael.Nm usleep
13*48352Scael.Nd suspend execution for interval of microseconds
14*48352Scael.Sh SYNOPSIS
15*48352Scael.Fd #include <unistd.h>
16*48352Scael.Ft void
17*48352Scael.Fn usleep "u_int microseconds"
18*48352Scael.Sh DESCRIPTION
19*48352ScaelThe
20*48352Scael.Fn sleep
21*48352Scaelfunction
22*48352Scaelsuspends execution of the calling process
23*48352Scaelfor
24*48352Scael.Fa microseconds
25*48352Scaelof time.
26*48352ScaelSystem activity or time spent in processing the
27*48352Scaelcall may lengthen the sleep slightly.
28*48352Scael.Pp
29*48352ScaelIf a timer is already running on the process its state is saved.
30*48352ScaelIf the value
31*48352Scael.Fa microseconds
32*48352Scaelis more than or equal to the remaining clock time for the saved timer,
33*48352Scaelthe sleep time is set to
34*48352Scaelthe remaining clock time.
35*48352ScaelThe state of the previous timer
36*48352Scaelis restored after
37*48352Scael.Fa microseconds
38*48352Scaelhas passed.
39*48352Scael.Pp
4028215SkarelsThis routine is implemented using
41*48352Scael.Xr setitimer 2 ;
4228215Skarelsit requires eight system calls each time it is invoked.
4328215SkarelsA similar but less compatible function can be obtained with a single
44*48352Scael.Xr select 2 ;
45*48352Scaelsuch a function would not restart after signals, but would not interfere
4628215Skarelswith other uses of
47*48352Scael.Xr setitimer .
48*48352Scael.Sh SEE ALSO
49*48352Scael.Xr setitimer 2 ,
50*48352Scael.Xr getitimer 2 ,
51*48352Scael.Xr sigpause 2 ,
52*48352Scael.Xr ualarm 3 ,
53*48352Scael.Xr sleep 3 ,
54*48352Scael.Xr alarm 3
55*48352Scael.Sh HISTORY
56*48352ScaelThe
57*48352Scael.Fn usleep
58*48352Scaelfunction appeared in
59*48352Scael.Bx 4.3 .
60