usleep

Suspends the calling thread for the specified number of microseconds.

Library:LibC
Classification:Single UNIX
Service:General C Services

Syntax

  #include <unistd.h> 
   
  int usleep (
     useconds_t   useconds);
  

Parameters

useconds

(IN) Specifies the microseconds to suspend the calling thread. The value must be less than 1,000,000.

Return Values

When the requested time has elapsed, returns 0. If it returns before the sleep interval has elapse, returns -1 and sets errno to indicate the error.

Decimal

Constant

Description

9

EINVAL

The time interval specified is 1,000,000 or more microseconds.

Remarks

Currently usleep is implemented on a mechanism that has precision of only a few milliseconds, so the time at which the calling thread returns cannot be more accurate than about 10 milliseconds.

See Also