1TIMER_GETOVERRUN(2) Linux Programmer's Manual TIMER_GETOVERRUN(2)
2
3
4
6 timer_getoverrun - get overrun count for a POSIX per-process timer
7
9 #include <time.h>
10
11 int timer_getoverrun(timer_t timerid);
12
13 Link with -lrt.
14
15 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
16
17 timer_getoverrun(): _POSIX_C_SOURCE >= 199309L
18
20 timer_getoverrun() returns the "overrun count" for the timer referred
21 to by timerid. An application can use the overrun count to accurately
22 calculate the number of timer expirations that would have occurred over
23 a given time interval. Timer overruns can occur both when receiving
24 expiration notifications via signals (SIGEV_SIGNAL), and via threads
25 (SIGEV_THREAD).
26
27 When expiration notifications are delivered via a signal, overruns can
28 occur as follows. Regardless of whether or not a real-time signal is
29 used for timer notifications, the system queues at most one signal per
30 timer. (This is the behavior specified by POSIX.1. The alternative,
31 queuing one signal for each timer expiration, could easily result in
32 overflowing the allowed limits for queued signals on the system.)
33 Because of system scheduling delays, or because the signal may be tem‐
34 porarily blocked, there can be a delay between the time when the noti‐
35 fication signal is generated and the time when it is delivered (e.g.,
36 caught by a signal handler) or accepted (e.g., using sigwaitinfo(2)).
37 In this interval, further timer expirations may occur. The timer over‐
38 run count is the number of additional timer expirations that occurred
39 between the time when the signal was generated and when it was deliv‐
40 ered or accepted.
41
42 Timer overruns can also occur when expiration notifications are deliv‐
43 ered via invocation of a thread, since there may be an arbitrary delay
44 between an expiration of the timer and the invocation of the notifica‐
45 tion thread, and in that delay interval, additional timer expirations
46 may occur.
47
49 On success, timer_getoverrun() returns the overrun count of the speci‐
50 fied timer; this count may be 0 if no overruns have occurred. On fail‐
51 ure, -1 is returned, and errno is set to indicate the error.
52
54 EINVAL timerid is not a valid timer ID.
55
57 This system call is available since Linux 2.6.
58
60 POSIX.1-2001, POSIX.1-2008.
61
63 When timer notifications are delivered via signals (SIGEV_SIGNAL), on
64 Linux it is also possible to obtain the overrun count via the si_over‐
65 run field of the siginfo_t structure (see sigaction(2)). This allows
66 an application to avoid the overhead of making a system call to obtain
67 the overrun count, but is a nonportable extension to POSIX.1.
68
69 POSIX.1 discusses timer overruns only in the context of timer notifica‐
70 tions using signals.
71
73 POSIX.1 specifies that if the timer overrun count is equal to or
74 greater than an implementation-defined maximum, DELAYTIMER_MAX, then
75 timer_getoverrun() should return DELAYTIMER_MAX. However, Linux does
76 not implement this feature: instead, if the timer overrun value exceeds
77 the maximum representable integer, the counter cycles, starting once
78 more from low values.
79
81 See timer_create(2).
82
84 clock_gettime(2), sigaction(2), signalfd(2), sigwaitinfo(2), timer_cre‐
85 ate(2), timer_delete(2), timer_settime(2), signal(7), time(7)
86
88 This page is part of release 5.04 of the Linux man-pages project. A
89 description of the project, information about reporting bugs, and the
90 latest version of this page, can be found at
91 https://www.kernel.org/doc/man-pages/.
92
93
94
95Linux 2017-09-15 TIMER_GETOVERRUN(2)