clock_nanosleep()

high resolution sleep with specifiable clock 

Advanced Realtime Function


SYNOPSIS

#include <time.h>

int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp, struct timespec *rmtp);


DESCRIPTION

The clock_nanosleep() function suspends the current thread. The TIMER_ABSTIME flag in flags determines whether or not the time value pointed to by rgtp is treated as an absolute time or a relative time.

When TIMER_ABSTIME is set, rgtp points to an absolute time and the clock_nanosleep() function suspends the current thread until one of the following conditions is met:

The clock_nanosleep() function returns immediately without suspending the thread if, at the time of the call, the specified clock already has a time value later than the time specified by rgtp.

When TIMER_ABSTIME is not set, rgtp points to a relative time interval and the clock_nanosleep() function suspends the current thread until one of the following conditions is met:

When this function suspends a thread, the length of the suspension may exceed the requested time because the tp value is automatically rounded to an integer multiple of the sleep resolution or because of other system activity. When TIMER_ABSTIME is set, the suspension time lasts until rqtp is reached unless interrupted by a signal. When TIMER_ABSTIME is not set, the suspension time will not exceed rqtp unless interrupted by a signal.

When TIMER_ABSTIME is not set and a signal interrupts the calling thread, the time remaining in the specified time interval returned in the timespec structure pointed to by rmtp. However, if rmtp is null, the time remaining is not returned.

The clock_nanosleep() function does not affect the action or blockage of any signal.


PARAMETERS

clock_id 

Indicates the clock to be used. On the NuTCRACKER Platform, only CLOCK_MONOTONIC and CLOCK_REALTIME may be used.

flags 

Contains the TIMER_ABSTIME flag which determines whether rqtp is an absolute or relative time value.

rmtp 

Points to a timespec structure where, when TIMER_ABSTIME is not set, the time remaining until the normal end of suspension is returned.

rqtp 

Points to a timespec structure containing a time value.


RETURN VALUES

When clock_nanosleep() returns because the requested suspension time has expire, it returns 0.

Otherwise, clock_nanosleep() returns one of the following:

EINTR 

A signal has interrupted the clock_nanosleep() function.

EINVAL 

The rqtp value is invalid or clock_id does not indicate a known clock, or clock_id specifies the CPU-time clock of the calling process.

ENOTSUP 

The clock_nanosleep() function is not supported for the specified clock_id. clock.


CONFORMANCE

UNIX 03.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

On the NuTCRACKER Platform, clock_nanosleep() is implemented as a call to nanosleep() for CLOCK_REALTIME with a non-absolute expiration.

The flag TIMER_RESUME can be used to configure clock_nanosleep() to wake the system from a suspended power conservation mode when the specified interval expires.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

api_intro

Functions:
_NutConf(), clock_getres(), nanosleep(), pthread_cond_timedwait(), sleep()


PTC MKS Toolkit 10.3 Documentation Build 39.