setitimer()

set interval timer 

Function


SYNOPSIS

#include <sys/time.h>

int setitimer (int which, const struct itimerval *value, struct itimerval *ovalue);


DESCRIPTION

The system provides each process with an interval timers. When the timer expires, a signal is sent to the process, and the timer (potentially) restarts.

The setitimer() function sets the timer specified by which to the value specified in the structure pointed to by value, and if ovalue is not a null pointer, stores the previous value of the timer in the structure pointed to by ovalue.

A timer value is defined by the itimerval structure. If it_value is non-zero, it indicates the time to the next timer expiration. If it_interval is non-zero, it specifies a value to be used in reloading it_value when the timer expires. Setting it_value to 0 disables a timer, regardless of the value of it_interval. Setting it_interval to 0 disables a timer after its next expiration (assuming it_value is non-zero).

Timers never expire before the requested time, dependent on the system timer resolution. Upon expiration, a signal is generated and the timer reset. If the timer expires while the process is active, the signal is delivered immediately when generated.


PARAMETERS

which 

Is the timer value to set. Must be ITIMER_REAL which decrements in real time, and delivers SIGALRM upon expiration.

value 

Points to a itimerval structure containing timer value to be set.

ovalue 

Points to a itimerval structure to hold old timer value.


RETURN VALUES

On success, zero is returned. On error, -1 is returned, and errno is set as follows:

EFAULT 

value or ovalue are not valid pointers

EINVAL 

which is not one of ITIMER_REAL, ITIMER_VIRTUAL, or ITIMER_PROF

ENOSYS 

which is ITIMER_VIRTUAL or ITIMER_PROF


CONFORMANCE

UNIX 98, with exceptions.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

The NuTCRACKER Platform supports the semantics of ITIMER_REAL, but not ITIMER_VIRTUAL or ITIMER_PROF. Calls using either of these unsupported timers return -1 and set errno to ENOSYS.

On 2012/8.1/2012R2/10/2016/2019, waitable timers with 100-nanosecond resolution are available, so setitimer() has microsecond accuracy.

The timers can be configured to wake the system from a suspended power conservation mode when the timer expires. See _NutConf() for more details.


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

Functions:
_NutConf(), alarm(), getitimer(), gettimeofday(), sigaction(), signal()


PTC MKS Toolkit 10.3 Documentation Build 39.