Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)
OSS Library Calls (t - v) usleep(3)
NAME
usleep - Suspends execution for an interval
LIBRARY
G-series native OSS processes: /G/system/sysnnn/zsptsrl
H-series and J-series OSS processes: /G/system/zdllnnn/zsptdll
32-bit H-series and J-series OSS processes that use the POSIX User Thread Model library: |
/G/system/zdllnnn/zputdll
64-bit H-series and J-series OSS processes that use the POSIX User Thread Model library: |
/G/system/zdllnnn/yputdll
SYNOPSIS
[#include <unistd.h>]
[#include <spthread.h>]
extern int usleep (unsigned int useconds);
PARAMETERS
useconds Specifies the number of microseconds to suspend execution. A value greater
than 1000000 causes the function call to fail and errno to be set to [EINVAL].
A value of 0 (zero) is ignored.
DESCRIPTION
The usleep( ) function suspends the calling process until one of the following occurs:
• The specified number of microseconds elapses.
• A signal is delivered to the process and the action of that signal is either to execute a
signal-catching function or to terminate the process.
The suspension time might be longer than requested due to the scheduling of other higher-
priority processes in the system.
The usleep( ) function is a thread-aware function that blocks only the thread calling it, without
blocking any other thread.
Use From the Guardian Environment
The actions of the usleep( ) function are undefined if it is called from a TNS or accelerated Guar-
dian process or from any privileged process.
Effects of SIGALRM
The SIGALRM signal does not affect the usleep( ) function any differently from any other sig-
nal. However, because in some implementations there is a dependency between SIGALRM and
usleep( ), it is appropriate to discuss SIGALRM here.
If a SIGALRM signal is generated for the calling process during execution of the usleep( ) func-
tion, and if the SIGALRM signal is being ignored or blocked from delivery, the usleep() func-
tion does not return. If the signal is being blocked, it remains pending when the function returns.
If a SIGALRM signal is generated for the calling process during execution of the usleep( ) func-
tion, except as a result of a prior call to the alarm( ) or ualarm( ) function, and if the SIGALRM
signal is not being ignored or blocked from delivery, the signal has no effect other than to cause
the usleep() function to return. Upon return, the signal is delivered immediately.
A signal-catching function that interrupts the usleep( ) function can examine or change the time
in which a SIGALRM signal is generated. Such actions have no effect on the behavior of the
usleep( ) function. The newly scheduled signal is not affected by the return from the usleep( )
function.
The effect of a SIGALRM signal is not changed if the process exits a usleep( ) function call by
using the siglongjmp( ) or longjmp( ) function. Whether the signal is blocked depends on the
527187-017 Hewlett-Packard Company 7−79