DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

timer_settime(S-osr5)


timer_settime, timer_gettime, timer_getoverrun -- per-process timers

Syntax

cc . . . -lsuds
#include <time.h>

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

int timer_gettime(timer_t timerid, struct itimerspec *value);

int timer_getoverrun(timer_t timerid);

Description

timer_settime- set process timer

timer_gettime- get process timer

timer_getoverrun- return timer overrun count

The timer_settime function sets the time until the next expiration of the timer specified by timerid. The time is set from the it_value member of the value argument. The timer is armed if the it_value member of value is non-zero. If the specified timer was already armed when timer_settime is called, this call resets the time until next expiration to the value specified. If the it_value member of value is zero, the timer is disarmed.

If the flag TIMER_ABSTIME is not set in the argument flags, timer_settime behaves as if the time until next expiration is set equal to the interval specified by the it_value member of value: that is, the timer expires in it_value nanoseconds (see Section 14.1.1 of IEEE Std 1003.1b-1993) from when the call is made. If the flag TIMER_ABSTIME is set in the argument flags, timer_settime behaves as if the time until next expiration is set equal to the difference between the absolute time specified by the it_value member of value and the current value of the clock associated with timerid: that is, the timer expires when the clock reaches the value specified by the it_value member of value. If the specified time has already passed, the function succeeds and the expiration notification is made.

The reload value of the timer is set to the value specified by the it_interval member of value. When a timer is armed with a non-zero it_interval, a periodic (or repetitive) timer is specified.

Time values that are between two consecutive non-negative integer multiples of the resolution of the specified timer are rounded up to the larger multiple of the resolution. Quantization error does not cause the timer to expire earlier than the rounded-up time value.

If the argument ovalue is not NULL, the function timer_settime stores, in the location referenced by ovalue, a value representing the previous amount of time before the timer would have expired or zero if the timer was disarmed, together with the previous timer reload value. The members of ovalue are subject to the resolution of the timer, and are the same values that would be returned by a timer_gettime call at that point in time.

The timer_gettime function stores the amount of time until the specified timer, timerid, expires and the timer's reload value into the space pointed to by the value argument. The it_value member of this structure contains the amount of time before the timer expires, or zero if the timer is disarmed. This value is returned as the interval until timer expiration, even if the timer was armed with absolute time. The it_interval member of value contains the reload value last set by timer_settime.

Only a single signal is queued to the process for a given timer at any point in time. When a timer for which a signal is still pending expires, no signal is queued, and a timer overrun occurs. The timer_getoverrun function returns the timer expiration overrun count for the timer specified by the timerid argument. The overrun count returned contains the number of extra timer expirations which occurred between the time the signal was generated (queued) and when it was delivered, up to but not including {DELAYTIMER_MAX}. If the number of such extra expirations is greater than or equal to {DELAYTIMER_MAX}, then the overrun count is set to {DELAYTIMER_MAX}. The value returned by timer_getoverrun applies to the most recent expiration signal delivery for the timer.

Return values

If the timer_settime or timer_gettime functions succeed, a value of 0 is returned. If an error occurs for either of these functions, the value -1 is returned, and errno is set to indicate the error. If the timer_getoverrun function succeeds, it returns the timer expiration overrun count as explained above.

Diagnostics

If the following condition occurs, the timer_settime, timer_gettime and timer_getoverrun functions return -1 and set errno to the corresponding value:

[EINVAL]
The timerid argument does not correspond to an ID returned by timer_create, but not yet deleted by timer_delete.

If the following condition occurs, the timer_settime function returns -1 and sets errno to the corresponding value:

[EINVAL]
A value structure specified a nanosecond value less than zero or greater than or equal to 1000 million.

See also

time(FP), timer_create(S-osr5)

Standards conformance

Text reprinted and/or adapted from IEEE Std 1003.1b-1993, IEEE Standard for Information Technology, POSIX Part 1: System Application Program Interface (API) Amendment 1: Realtime Extensions [C Language], copyright © 1993 by the Institute of Electrical and Electronics Engineers, Inc. The IEEE takes no responsibility for and will assume no liability for damages resulting from the reader's misinterpretation of said information resulting from the placement and context in this publication. Information is reproduced with the permission of the IEEE.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005