usleep - suspend execution for interval in microseconds
int usleep(useconds_t useconds);
The usleep() function suspends the caller from execution for
the number of microseconds specified by the useconds argu-
ment. (A microsecond is .000001 seconds.) Because of other
activity, or because of the time spent in processing the
call, the actual suspension time may be longer than the
amount of time specified.
If the value of useconds is 0, then the call has no effect.
In a single-threaded program (one not linked with -lthread
or -lpthread), the usleep() function uses the process's
realtime interval timer to indicate to the system when the
process should be woken up.
There is one real-time interval timer for each process. The
usleep() function will not interfere with a previous setting
of this timer. If the process has set this timer prior to
calling usleep(), and if the time specified by useconds
equals or exceeds the interval timer's prior setting, the
caller will be woken up shortly before the timer was set to
Interactions between usleep() and either alarm(2) or
sleep(3C) are unspecified.
In a multithreaded program (one linked with -lthread or
-lpthread), usleep() is implemented by a call to
nanosleep(3RT) and does not modify the state of the alarm
signal or the realtime interval timer. There is no interac-
tion between this version of usleep() and either alarm(2) or
On completion, usleep() returns 0. There are no error
No errors are returned.
The usleep() function is included for its historical usage.
The nanosleep(3RT) function is preferred over this function.
See attributes(5) for descriptions of the following attri-
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
| MT-Level | Safe |
alarm(2), setitimer(2), sigaction(2), sigprocmask(2),
nanosleep(3RT), sleep(3C), ualarm(3C), attributes(5)
In a multithreaded program, only the invoking thread is
suspended from execution.
Man(1) output converted with