Sleep for some specified amount of time.
Syntax
#include <time.h>
int nanosleep (const struct timespec *time, struct timespec *rem);
Parameters
-
time
The time to sleep for.
-
rem
This argument is currently ignored.
Return Value
The return value is null if successful. Otherwise, the return value is negative and errno is set:
-
EINVAL
The
time
argument is not valid.
Remarks
The time resulution is decided by the system tick timer, which operates at 1 KHz (1 millisecond resolution).
A process may be worken from sleep if it receives a signal. Sleeping is therefore a good way to preserve CPU when waiting for such signals.