Sun Microsystems, Inc.
spacerspacer
spacer   www.sun.com docs.sun.com | | |  
spacer
black dot
   
A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   P   Q   R   S   T   U   V   W   X   Y   Z
    
 
Standard C Library Functionsusleep(3C)


NAME

 usleep - suspend execution for interval in microseconds

SYNOPSIS

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

DESCRIPTION

 

The usleep() function suspends the caller from execution for the number of microseconds specified by the useconds argument. (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 expire.

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 interaction between this version of usleep() and either alarm(2) or sleep(3C).

RETURN VALUES

 

On completion, usleep() returns 0. There are no error retruns.

ERRORS

 

No errors are returned.

USAGE

 

The usleep() function is included for its historical usage. The nanosleep(3RT) function is preferred over this function.

ATTRIBUTES

 

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPEATTRIBUTE VALUE
MT-LevelSafe

SEE ALSO

 

alarm(2), setitimer(2), sigaction(2), sigprocmask(2), nanosleep(3RT), sleep(3C), ualarm(3C), attributes(5)

NOTES

 

In a multithreaded program, only the invoking thread is suspended from execution.


SunOS 5.9Go To TopLast Changed 23 Jul 2001

 
      
      
Copyright 2002 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.