]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/timer_getoverrun.2
getent.1, ldd.1, locale.1, localedef.1, memusage.1, memusagestat.1, mtrace.1, _exit...
[thirdparty/man-pages.git] / man2 / timer_getoverrun.2
1 .\" Copyright (c) 2009 Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .TH TIMER_GETOVERRUN 2 2021-03-22 Linux "Linux Programmer's Manual"
27 .SH NAME
28 timer_getoverrun \- get overrun count for a POSIX per-process timer
29 .SH SYNOPSIS
30 .nf
31 .B #include <time.h>
32 .PP
33 .BI "int timer_getoverrun(timer_t " timerid );
34 .fi
35 .PP
36 Link with \fI\-lrt\fP.
37 .PP
38 .RS -4
39 Feature Test Macro Requirements for glibc (see
40 .BR feature_test_macros (7)):
41 .RE
42 .PP
43 .BR timer_getoverrun ():
44 .nf
45 _POSIX_C_SOURCE >= 199309L
46 .fi
47 .SH DESCRIPTION
48 .BR timer_getoverrun ()
49 returns the "overrun count" for the timer referred to by
50 .IR timerid .
51 An application can use the overrun count to accurately calculate the number
52 of timer expirations that would have occurred over a given time interval.
53 Timer overruns can occur both when receiving expiration notifications
54 via signals
55 .RB ( SIGEV_SIGNAL ),
56 and via threads
57 .RB ( SIGEV_THREAD ).
58 .PP
59 When expiration notifications are delivered via a signal,
60 overruns can occur as follows.
61 Regardless of whether or not a real-time signal is used for
62 timer notifications,
63 the system queues at most one signal per timer.
64 (This is the behavior specified by POSIX.1.
65 The alternative, queuing one signal for each timer expiration,
66 could easily result in overflowing the allowed limits for
67 queued signals on the system.)
68 Because of system scheduling delays,
69 or because the signal may be temporarily blocked,
70 there can be a delay between the time when the notification
71 signal is generated and the time when it
72 is delivered (e.g., caught by a signal handler) or accepted (e.g., using
73 .BR sigwaitinfo (2)).
74 In this interval, further timer expirations may occur.
75 The timer overrun count is the number of additional
76 timer expirations that occurred between the time when the signal
77 was generated and when it was delivered or accepted.
78 .PP
79 Timer overruns can also occur when expiration notifications
80 are delivered via invocation of a thread,
81 since there may be an arbitrary delay between an expiration of the timer
82 and the invocation of the notification thread,
83 and in that delay interval, additional timer expirations may occur.
84 .SH RETURN VALUE
85 On success,
86 .BR timer_getoverrun ()
87 returns the overrun count of the specified timer;
88 this count may be 0 if no overruns have occurred.
89 On failure, \-1 is returned, and
90 .I errno
91 is set to indicate the error.
92 .SH ERRORS
93 .TP
94 .B EINVAL
95 .I timerid
96 is not a valid timer ID.
97 .SH VERSIONS
98 This system call is available since Linux 2.6.
99 .SH CONFORMING TO
100 POSIX.1-2001, POSIX.1-2008.
101 .SH NOTES
102 When timer notifications are delivered via signals
103 .RB ( SIGEV_SIGNAL ),
104 on Linux it is also possible to obtain the overrun count via the
105 .I si_overrun
106 field of the
107 .I siginfo_t
108 structure (see
109 .BR sigaction (2)).
110 This allows an application to avoid the overhead of making
111 a system call to obtain the overrun count,
112 but is a nonportable extension to POSIX.1.
113 .PP
114 POSIX.1 discusses timer overruns only in the context of
115 timer notifications using signals.
116 .\" FIXME . Austin bug filed, 11 Feb 09
117 .\" https://www.austingroupbugs.net/view.php?id=95
118 .SH BUGS
119 POSIX.1 specifies that if the timer overrun count
120 is equal to or greater than an implementation-defined maximum,
121 .BR DELAYTIMER_MAX ,
122 then
123 .BR timer_getoverrun ()
124 should return
125 .BR DELAYTIMER_MAX .
126 However, before Linux 4.19,
127 .\" http://bugzilla.kernel.org/show_bug.cgi?id=12665
128 if the timer overrun value exceeds the maximum representable integer,
129 the counter cycles, starting once more from low values.
130 Since Linux 4.19,
131 .\" commit 78c9c4dfbf8c04883941445a195276bb4bb92c76
132 .BR timer_getoverrun ()
133 returns
134 .B DELAYTIMER_MAX
135 (defined as
136 .B INT_MAX
137 in
138 .IR <limits.h> )
139 in this case (and the overrun value is reset to 0).
140 .SH EXAMPLES
141 See
142 .BR timer_create (2).
143 .SH SEE ALSO
144 .BR clock_gettime (2),
145 .BR sigaction (2),
146 .BR signalfd (2),
147 .BR sigwaitinfo (2),
148 .BR timer_create (2),
149 .BR timer_delete (2),
150 .BR timer_settime (2),
151 .BR signal (7),
152 .BR time (7)