1TIMER_GETOVERRUN(3P) POSIX Programmer's Manual TIMER_GETOVERRUN(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 timer_getoverrun, timer_gettime, timer_settime - per-process timers
13 (REALTIME)
14
16 #include <time.h>
17
18 int timer_getoverrun(timer_t timerid);
19 int timer_gettime(timer_t timerid, struct itimerspec *value);
20 int timer_settime(timer_t timerid, int flags,
21 const struct itimerspec *restrict value,
22 struct itimerspec *restrict ovalue);
23
24
26 The timer_gettime() function shall store the amount of time until the
27 specified timer, timerid, expires and the reload value of the timer
28 into the space pointed to by the value argument. The it_value member of
29 this structure shall contain the amount of time before the timer
30 expires, or zero if the timer is disarmed. This value is returned as
31 the interval until timer expiration, even if the timer was armed with
32 absolute time. The it_interval member of value shall contain the reload
33 value last set by timer_settime().
34
35 The timer_settime() function shall set the time until the next expira‐
36 tion of the timer specified by timerid from the it_value member of the
37 value argument and arm the timer if the it_value member of value is
38 non-zero. If the specified timer was already armed when timer_settime()
39 is called, this call shall reset the time until next expiration to the
40 value specified. If the it_value member of value is zero, the timer
41 shall be disarmed. The effect of disarming or resetting a timer with
42 pending expiration notifications is unspecified.
43
44 If the flag TIMER_ABSTIME is not set in the argument flags, timer_set‐
45 time() shall behave as if the time until next expiration is set to be
46 equal to the interval specified by the it_value member of value. That
47 is, the timer shall expire in it_value nanoseconds from when the call
48 is made. If the flag TIMER_ABSTIME is set in the argument flags,
49 timer_settime() shall behave as if the time until next expiration is
50 set to be equal to the difference between the absolute time specified
51 by the it_value member of value and the current value of the clock
52 associated with timerid. That is, the timer shall expire when the
53 clock reaches the value specified by the it_value member of value. If
54 the specified time has already passed, the function shall succeed and
55 the expiration notification shall be made.
56
57 The reload value of the timer shall be set to the value specified by
58 the it_interval member of value. When a timer is armed with a non-zero
59 it_interval, a periodic (or repetitive) timer is specified.
60
61 Time values that are between two consecutive non-negative integer mul‐
62 tiples of the resolution of the specified timer shall be rounded up to
63 the larger multiple of the resolution. Quantization error shall not
64 cause the timer to expire earlier than the rounded time value.
65
66 If the argument ovalue is not NULL, the timer_settime() function shall
67 store, in the location referenced by ovalue, a value representing the
68 previous amount of time before the timer would have expired, or zero if
69 the timer was disarmed, together with the previous timer reload value.
70 Timers shall not expire before their scheduled time.
71
72 Only a single signal shall be queued to the process for a given timer
73 at any point in time. When a timer for which a signal is still pending
74 expires, no signal shall be queued, and a timer overrun shall occur.
75 When a timer expiration signal is delivered to or accepted by a
76 process, if the implementation supports the Realtime Signals Extension,
77 the timer_getoverrun() function shall return the timer expiration over‐
78 run count for the specified timer. The overrun count returned contains
79 the number of extra timer expirations that occurred between the time
80 the signal was generated (queued) and when it was delivered or
81 accepted, up to but not including an implementation-defined maximum of
82 {DELAYTIMER_MAX}. If the number of such extra expirations is greater
83 than or equal to {DELAYTIMER_MAX}, then the overrun count shall be set
84 to {DELAYTIMER_MAX}. The value returned by timer_getoverrun() shall
85 apply to the most recent expiration signal delivery or acceptance for
86 the timer. If no expiration signal has been delivered for the timer,
87 or if the Realtime Signals Extension is not supported, the return value
88 of timer_getoverrun() is unspecified.
89
91 If the timer_getoverrun() function succeeds, it shall return the timer
92 expiration overrun count as explained above.
93
94 If the timer_gettime() or timer_settime() functions succeed, a value of
95 0 shall be returned.
96
97 If an error occurs for any of these functions, the value -1 shall be
98 returned, and errno set to indicate the error.
99
101 The timer_getoverrun(), timer_gettime(), and timer_settime() functions
102 shall fail if:
103
104 EINVAL The timerid argument does not correspond to an ID returned by
105 timer_create() but not yet deleted by timer_delete().
106
107
108 The timer_settime() function shall fail if:
109
110 EINVAL A value structure specified a nanosecond value less than zero or
111 greater than or equal to 1000 million, and the it_value member
112 of that structure did not specify zero seconds and nanoseconds.
113
114
115 The following sections are informative.
116
118 None.
119
121 None.
122
124 Practical clocks tick at a finite rate, with rates of 100 hertz and
125 1000 hertz being common. The inverse of this tick rate is the clock
126 resolution, also called the clock granularity, which in either case is
127 expressed as a time duration, being 10 milliseconds and 1 millisecond
128 respectively for these common rates. The granularity of practical
129 clocks implies that if one reads a given clock twice in rapid succes‐
130 sion, one may get the same time value twice; and that timers must wait
131 for the next clock tick after the theoretical expiration time, to
132 ensure that a timer never returns too soon. Note also that the granu‐
133 larity of the clock may be significantly coarser than the resolution of
134 the data format used to set and get time and interval values. Also note
135 that some implementations may choose to adjust time and/or interval
136 values to exactly match the ticks of the underlying clock.
137
138 This volume of IEEE Std 1003.1-2001 defines functions that allow an
139 application to determine the implementation-supported resolution for
140 the clocks and requires an implementation to document the resolution
141 supported for timers and nanosleep() if they differ from the supported
142 clock resolution. This is more of a procurement issue than a runtime
143 application issue.
144
146 None.
147
149 clock_getres(), timer_create(), the Base Definitions volume of
150 IEEE Std 1003.1-2001, <time.h>
151
153 Portions of this text are reprinted and reproduced in electronic form
154 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
155 -- Portable Operating System Interface (POSIX), The Open Group Base
156 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
157 Electrical and Electronics Engineers, Inc and The Open Group. In the
158 event of any discrepancy between this version and the original IEEE and
159 The Open Group Standard, the original IEEE and The Open Group Standard
160 is the referee document. The original Standard can be obtained online
161 at http://www.opengroup.org/unix/online.html .
162
163
164
165IEEE/The Open Group 2003 TIMER_GETOVERRUN(3P)