[Previous]
[Contents]
[Next]

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 );

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, the timer is disarmed.

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

If the timer isn't disarmed, the flags argument determines the type of timer to arm. The flags argument can contain any of the following control bits:

TIMER_ABSTIME
If this bit is set, the it_value represents an absolute expiration date in seconds and nanoseconds from 1970. If the date specified has already passed, the function will succeed and the expiration notice will be made.

If this bit isn't set, the it_value represents a relative expiration period that will be offset from the current system time by the specified number of seconds and nanoseconds.

TIMER_ADDREL
This bit is NOT to be set in conjunction with TIMER_ABSTIME. It is only to be used with a relative expiration period.

The TIMER_ADDREL bit specifies that the relative expiration period is to be an offset from the current value of the running timer, rather than that of the system time.

TIMER_AUTO_RELEASE
If this bit is set, the timer is released automatically when it expires.
TIMER_PRESERVE_EXEC
If this bit is set, timers will be preserved across an exec... call. By default, timers are deleted across an exec.... Note that timers are never preserved across a fork() or spawn... call, regardless of the state of the TIMER_PRESERVE_EXEC flag.

If the ovalue parameter isn't NULL, on return from this function it will contain 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().

Returns:

0
Success
-1
An error occurred. errno is set to indicate the error.

Errors:

EINVAL
The timer timerid isn't attached to the calling process.

Examples:

See timer_create().

Classification:

POSIX 1003.4

Safety:
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

clock_getres(), clock_gettime(), clock_setres(), clock_settime(), errno, nanosleep(), sleep(), timer_create(), timer_delete(), timer_gettime(), ticksize utility


[Previous]
[Contents]
[Next]