Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ nanosleep(3P4) — CX/UX 6.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

clock_getres(3P4)

hrtconfig(1M)

server_wake1(2)

nanosleep(3P4)

NAME

nanosleep − high-resolution sleep

SYNOPSIS

#include <sys/types.h>
#include <time.h>

int nanosleep(rqtp, rmtp)
struct timespec  ∗rqtp
struct timespec  ∗rmtp

DESCRIPTION

The nanosleep function causes the current process to be suspended from execution until either the time interval specified by the rqtp argument has elapsed, or a signal is delivered to the calling process and its action is to invoke a signal-catching function or to terminate the process.  The nanosleep function has no effect on the action or blockage of any signal.  The rmtp argument is ignored. 

The timespec structure definition is:

struct timespec {

time_t  tv_sec; /∗ seconds ∗/
long    tv_nsec; /∗ nanoseconds ∗/

}

In order to provide a high resolution in the nanosleep function, a RTC should be configured to be used by the high-resolution callout queue using hrtconfig(1M). 

RETURN VALUE

If the nanosleep function returns because the requested time has elapsed, the return value is zero. 

If the nanosleep function returns because it has been interrupted by a signal, the return value is +1. 

If any of the following conditions occur, the nanosleep function shall return -1 and set errno to the corresponding value:

[EINVAL] The rqtp argument specified a nanosecond value less than zero or greater than or equal to 1 billion. 

[EINVAL] The rqtp argument specified a time that exceeds the maximum time supported by the nanosleep function. 

FILES

/usr/lib/libposix4.a

SEE ALSO

clock_getres(3P4), hrtconfig(1M), server_wake1(2). 

BUGS

POSIX 1003.4 provides a means of returning the remaining time when the nanosleep function is interrupted by a signal and the rmtp argument is non-NULL.  This is not supported in this release of nanosleep. 

The process may be wakened from nanosleep via a server_wake1(2) call.  The nanosleep function will detect this occurrence and return a +1 to the user indicating the call was interrupted. 

WARNING

The interface to nanosleep is based on IEEE Draft Standard P1003.4/D12.  This is an unapproved draft, subject to change.  Use of information contained in this unapproved draft is at your own risk.  This interface will change to reflect any changes made by future drafts of POSIX 1003.4. 

CX/UX Programmer’s Reference Manual

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026