1timer_getoverrun(2) System Calls Manual timer_getoverrun(2)
2
3
4
6 timer_getoverrun - get overrun count for a POSIX per-process timer
7
9 Real-time library (librt, -lrt)
10
12 #include <time.h>
13
14 int timer_getoverrun(timer_t timerid);
15
16 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
17
18 timer_getoverrun():
19 _POSIX_C_SOURCE >= 199309L
20
22 timer_getoverrun() returns the "overrun count" for the timer referred
23 to by timerid. An application can use the overrun count to accurately
24 calculate the number of timer expirations that would have occurred over
25 a given time interval. Timer overruns can occur both when receiving
26 expiration notifications via signals (SIGEV_SIGNAL), and via threads
27 (SIGEV_THREAD).
28
29 When expiration notifications are delivered via a signal, overruns can
30 occur as follows. Regardless of whether or not a real-time signal is
31 used for timer notifications, the system queues at most one signal per
32 timer. (This is the behavior specified by POSIX.1. The alternative,
33 queuing one signal for each timer expiration, could easily result in
34 overflowing the allowed limits for queued signals on the system.) Be‐
35 cause of system scheduling delays, or because the signal may be tempo‐
36 rarily blocked, there can be a delay between the time when the notifi‐
37 cation signal is generated and the time when it is delivered (e.g.,
38 caught by a signal handler) or accepted (e.g., using sigwaitinfo(2)).
39 In this interval, further timer expirations may occur. The timer over‐
40 run count is the number of additional timer expirations that occurred
41 between the time when the signal was generated and when it was deliv‐
42 ered or accepted.
43
44 Timer overruns can also occur when expiration notifications are deliv‐
45 ered via invocation of a thread, since there may be an arbitrary delay
46 between an expiration of the timer and the invocation of the notifica‐
47 tion thread, and in that delay interval, additional timer expirations
48 may occur.
49
51 On success, timer_getoverrun() returns the overrun count of the speci‐
52 fied timer; this count may be 0 if no overruns have occurred. On fail‐
53 ure, -1 is returned, and errno is set to indicate the error.
54
56 EINVAL timerid is not a valid timer ID.
57
59 When timer notifications are delivered via signals (SIGEV_SIGNAL), on
60 Linux it is also possible to obtain the overrun count via the si_over‐
61 run field of the siginfo_t structure (see sigaction(2)). This allows
62 an application to avoid the overhead of making a system call to obtain
63 the overrun count, but is a nonportable extension to POSIX.1.
64
65 POSIX.1 discusses timer overruns only in the context of timer notifica‐
66 tions using signals.
67
69 POSIX.1-2008.
70
72 Linux 2.6. POSIX.1-2001.
73
75 POSIX.1 specifies that if the timer overrun count is equal to or
76 greater than an implementation-defined maximum, DELAYTIMER_MAX, then
77 timer_getoverrun() should return DELAYTIMER_MAX. However, before Linux
78 4.19, if the timer overrun value exceeds the maximum representable in‐
79 teger, the counter cycles, starting once more from low values. Since
80 Linux 4.19, timer_getoverrun() returns DELAYTIMER_MAX (defined as
81 INT_MAX in <limits.h>) in this case (and the overrun value is reset to
82 0).
83
85 See timer_create(2).
86
88 clock_gettime(2), sigaction(2), signalfd(2), sigwaitinfo(2), timer_cre‐
89 ate(2), timer_delete(2), timer_settime(2), signal(7), time(7)
90
91
92
93Linux man-pages 6.05 2023-03-30 timer_getoverrun(2)