xref: /csrg-svn/lib/libc/gen/usleep.3 (revision 61111)
1*61111Sbostic.\" Copyright (c) 1986, 1991, 1993
2*61111Sbostic.\"	The Regents of the University of California.  All rights reserved.
325789Smckusick.\"
448352Scael.\" %sccs.include.redist.man%
525789Smckusick.\"
6*61111Sbostic.\"     @(#)usleep.3	8.1 (Berkeley) 06/04/93
748352Scael.\"
848352Scael.Dd
948352Scael.Dt USLEEP 3
1048352Scael.Os BSD 4.3
1148352Scael.Sh NAME
1248352Scael.Nm usleep
1348352Scael.Nd suspend execution for interval of microseconds
1448352Scael.Sh SYNOPSIS
1548352Scael.Fd #include <unistd.h>
1648352Scael.Ft void
1748352Scael.Fn usleep "u_int microseconds"
1848352Scael.Sh DESCRIPTION
1948352ScaelThe
2059202Shibler.Fn usleep
2148352Scaelfunction
2248352Scaelsuspends execution of the calling process
2348352Scaelfor
2448352Scael.Fa microseconds
2548352Scaelof time.
2648352ScaelSystem activity or time spent in processing the
2748352Scaelcall may lengthen the sleep slightly.
2848352Scael.Pp
2948352ScaelIf a timer is already running on the process its state is saved.
3048352ScaelIf the value
3148352Scael.Fa microseconds
3248352Scaelis more than or equal to the remaining clock time for the saved timer,
3348352Scaelthe sleep time is set to
3448352Scaelthe remaining clock time.
3548352ScaelThe state of the previous timer
3648352Scaelis restored after
3748352Scael.Fa microseconds
3848352Scaelhas passed.
3948352Scael.Pp
4028215SkarelsThis routine is implemented using
4148352Scael.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
4448352Scael.Xr select 2 ;
4548352Scaelsuch a function would not restart after signals, but would not interfere
4628215Skarelswith other uses of
4748352Scael.Xr setitimer .
4848352Scael.Sh SEE ALSO
4948352Scael.Xr setitimer 2 ,
5048352Scael.Xr getitimer 2 ,
5148352Scael.Xr sigpause 2 ,
5248352Scael.Xr ualarm 3 ,
5348352Scael.Xr sleep 3 ,
5448352Scael.Xr alarm 3
5548352Scael.Sh HISTORY
5648352ScaelThe
5748352Scael.Fn usleep
5848352Scaelfunction appeared in
5948352Scael.Bx 4.3 .
60