Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

timer_settime()

Set the expiration time for a timer

Synopsis:

#include <time.h>

int timer_settime( timer_t timerid,
                   int flags,
                   struct itimerspec * value,
                   struct itimerspec * ovalue );

Arguments:

timerid
A timer_t object that holds a timer ID, as set by timer_create().
flags
The type of timer to arm if you aren't disarming the timer. The valid bits include:
value
A pointer to a itimerspec structure that specifies the value that you want to set for the timer's time until expiry. For more information, see timer_gettime().
ovalue
NULL, or a pointer to a itimerspec structure that the function fills in with the timer's former time until expiry.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The timer_settime() function sets the expiration time of the timer specified by timerid from the it_value member of the value argument. If the it_value structure member of value is zero, then the timer is disarmed.

If the it_interval member of value is nonzero, then it specifies a repeat rate that is added to the timer once the it_value period has expired. Subsequently, the timer is automatically rearmed, causing it to become continuous with a period of it_interval.

If the ovalue parameter isn't NULL, then on return from this function it contains a value representing the previous amount of time left before the timer was to have expired, or zero if the timer was disarmed. The previous interval timer period is also stored in the it_interval member.

The timerid is local to the calling process, and must have been created using timer_create().


Note: Because of the nature of time measurement, the timer might actually expire after the specified time. For more information, see the Tick, Tock: Understanding the Neutrino Microkernel's Concept of Time chapter of the QNX Neutrino Programmer's Guide.

Returns:

0
Success.
-1
An error occurred (errno is set).

Errors:

EFAULT
A fault occurred trying to access the buffers provided.
EINVAL
The timer timerid isn't attached to the calling process or the number of nanoseconds specified by the tv_nsec member of one of the timespec structures in the itimerspec structure pointed to by value is less than zero or greater than or equal to 1000 million.

Examples:

See timer_create().

Classification:

POSIX 1003.1 TMR

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

clock_getres(), clock_gettime(), clock_settime(), errno, nanosleep(), sleep(), timer_create(), timer_delete(), timer_getexpstatus(), timer_getoverrun(), timer_gettime()

Clocks, Timers, and Getting a Kick Every So Often chapter of Getting Started with QNX Neutrino

Tick, Tock: Understanding the Neutrino Microkernel's Concept of Time chapter of the QNX Neutrino Programmer's Guide