share/mk/: build-html: Don't build mbind.2 and set_mempolicy.2
[man-pages.git] / man2 / timer_getoverrun.2
blobedc1ff6ab594d6978c95b8c0e596b154e0d047fb
1 .\" Copyright (c) 2009 Linux Foundation, written by Michael Kerrisk
2 .\"     <mtk.manpages@gmail.com>
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .TH timer_getoverrun 2 (date) "Linux man-pages (unreleased)"
7 .SH NAME
8 timer_getoverrun \- get overrun count for a POSIX per-process timer
9 .SH LIBRARY
10 Real-time library
11 .RI ( librt ", " \-lrt )
12 .SH SYNOPSIS
13 .nf
14 .B  #include <time.h>
16 .BI "int timer_getoverrun(timer_t " timerid );
17 .fi
19 .RS -4
20 Feature Test Macro Requirements for glibc (see
21 .BR feature_test_macros (7)):
22 .RE
24 .BR timer_getoverrun ():
25 .nf
26     _POSIX_C_SOURCE >= 199309L
27 .fi
28 .SH DESCRIPTION
29 .BR timer_getoverrun ()
30 returns the "overrun count" for the timer referred to by
31 .IR timerid .
32 An application can use the overrun count to accurately calculate the number
33 of timer expirations that would have occurred over a given time interval.
34 Timer overruns can occur both when receiving expiration notifications
35 via signals
36 .RB ( SIGEV_SIGNAL ),
37 and via threads
38 .RB ( SIGEV_THREAD ).
40 When expiration notifications are delivered via a signal,
41 overruns can occur as follows.
42 Regardless of whether or not a real-time signal is used for
43 timer notifications,
44 the system queues at most one signal per timer.
45 (This is the behavior specified by POSIX.1.
46 The alternative, queuing one signal for each timer expiration,
47 could easily result in overflowing the allowed limits for
48 queued signals on the system.)
49 Because of system scheduling delays,
50 or because the signal may be temporarily blocked,
51 there can be a delay between the time when the notification
52 signal is generated and the time when it
53 is delivered (e.g., caught by a signal handler) or accepted (e.g., using
54 .BR sigwaitinfo (2)).
55 In this interval, further timer expirations may occur.
56 The timer overrun count is the number of additional
57 timer expirations that occurred between the time when the signal
58 was generated and when it was delivered or accepted.
60 Timer overruns can also occur when expiration notifications
61 are delivered via invocation of a thread,
62 since there may be an arbitrary delay between an expiration of the timer
63 and the invocation of the notification thread,
64 and in that delay interval, additional timer expirations may occur.
65 .SH RETURN VALUE
66 On success,
67 .BR timer_getoverrun ()
68 returns the overrun count of the specified timer;
69 this count may be 0 if no overruns have occurred.
70 On failure, \-1 is returned, and
71 .I errno
72 is set to indicate the error.
73 .SH ERRORS
74 .TP
75 .B EINVAL
76 .I timerid
77 is not a valid timer ID.
78 .SH VERSIONS
79 When timer notifications are delivered via signals
80 .RB ( SIGEV_SIGNAL ),
81 on Linux it is also possible to obtain the overrun count via the
82 .I si_overrun
83 field of the
84 .I siginfo_t
85 structure (see
86 .BR sigaction (2)).
87 This allows an application to avoid the overhead of making
88 a system call to obtain the overrun count,
89 but is a nonportable extension to POSIX.1.
91 POSIX.1 discusses timer overruns only in the context of
92 timer notifications using signals.
93 .\" FIXME . Austin bug filed, 11 Feb 09
94 .\" https://www.austingroupbugs.net/view.php?id=95
95 .SH STANDARDS
96 POSIX.1-2008.
97 .SH HISTORY
98 Linux 2.6.
99 POSIX.1-2001.
100 .SH BUGS
101 POSIX.1 specifies that if the timer overrun count
102 is equal to or greater than an implementation-defined maximum,
103 .BR DELAYTIMER_MAX ,
104 then
105 .BR timer_getoverrun ()
106 should return
107 .BR DELAYTIMER_MAX .
108 However, before Linux 4.19,
109 .\" http://bugzilla.kernel.org/show_bug.cgi?id=12665
110 if the timer overrun value exceeds the maximum representable integer,
111 the counter cycles, starting once more from low values.
112 Since Linux 4.19,
113 .\" commit 78c9c4dfbf8c04883941445a195276bb4bb92c76
114 .BR timer_getoverrun ()
115 returns
116 .B DELAYTIMER_MAX
117 (defined as
118 .B INT_MAX
120 .IR <limits.h> )
121 in this case (and the overrun value is reset to 0).
122 .SH EXAMPLES
124 .BR timer_create (2).
125 .SH SEE ALSO
126 .BR clock_gettime (2),
127 .BR sigaction (2),
128 .BR signalfd (2),
129 .BR sigwaitinfo (2),
130 .BR timer_create (2),
131 .BR timer_delete (2),
132 .BR timer_settime (2),
133 .BR signal (7),
134 .BR time (7)