Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 |
both | POSIX(ON) |
#define _XOPEN_SOURCE_EXTENDED 1
#include <unistd.h>
int usleep(useconds_t useconds);
The usleep() function suspends thread execution for the number of microseconds specified by the useconds argument. Because of other activity, or because of the time spent processing the call, the actual suspension time may be longer than the amount of time specified.
The useconds argument must be less than 1,000,000. If the value of useconds is 0, then the call has no effect.
The usleep() function will not interfere with a previous setting of the real-time interval timer. If the thread has set this timer before calling usleep(), and if the time specified by useconds equals or exceeds the interval timer's prior setting, then the thread will be awakened when the previously set timer interval expires.
If successful, usleep() returns 0.