1 .\" Copyright (c) 2009 Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .TH TIMER_GETOVERRUN 2 2009-02-20 Linux "Linux Programmer's Manual"
25 timer_getoverrun \- get overrun count for a POSIX per-process timer
30 .BI "int timer_getoverrun(timer_t " timerid );
33 Link with \fI\-lrt\fP.
36 Feature Test Macro Requirements for glibc (see
37 .BR feature_test_macros (7)):
40 .BR timer_getoverrun ():
41 _POSIX_C_SOURCE >= 199309
43 .BR timer_getoverrun ()
44 returns the "overrun count" for the timer referred to by
46 An application can use the overrun count to accurately calculate the number
47 of timer expirations that would have occurred over a given time interval.
48 Timer overruns can occur both when receiving expiration notifications
54 When expiration notifications are delivered via a signal,
55 overruns can occur as follows.
56 Regardless of whether or not a real-time signal is used for
58 the system queues at most one signal per timer.
59 (This is the behavior specified by POSIX.1-2001.
60 The alternative, queuing one signal for each timer expiration,
61 could easily result in overflowing the allowed limits for
62 queued signals on the system.)
63 Because of system scheduling delays,
64 or because the signal may be temporarily blocked,
65 there can be a delay between the time when the notification
66 signal is generated and the time when it
67 is delivered (e.g., caught by a signal handler) or accepted (e.g., using
69 In this interval, further timer expirations may occur.
70 The timer overrun count is the number of additional
71 timer expirations that occurred between the time when the signal
72 was generated and when it was delivered or accepted.
74 Timer overruns can also occur when expiration notifications
75 are delivered via invocation of a thread,
76 since there may be an arbitrary delay between an expiration of the timer
77 and the invocation of the notification thread,
78 and in that delay interval, additional timer expirations may occur
81 .BR timer_getoverrun ()
82 returns the overrun count of the specified timer;
83 this count may be 0 if no overruns have occurred.
84 On failure, \-1 is returned, and
86 is set to indicate the error.
91 is not a valid timer ID.
93 This system call is available since Linux 2.6.
97 When timer notifications are delivered via signals
99 on Linux it is also possible to obtain the overrun count via the
105 This allows an application to avoid the overhead of making
106 a system call to obtain the overrun count,
107 but is a nonportable extension to POSIX.1-2001.
109 POSIX.1-2001 only discusses timer overruns in the context of
110 timer notifications using signals.
111 .\" FIXME . Austin bug filed, 11 Feb 09
113 POSIX.1-2001 specifies that if the timer overrun count
114 is equal to or greater than an implementation-defined maximum,
117 .BR timer_getoverrun ()
120 However, Linux does not implement this feature: instead,
121 if the timer overrun value exceeds the maximum representable integer,
122 the counter cycles, starting once more from low values.
123 .\" Bug filed: http://bugzilla.kernel.org/show_bug.cgi?id=12665
124 .\" http://thread.gmane.org/gmane.linux.kernel/113276/
127 .BR timer_create (2).
129 .BR clock_gettime (2),
133 .BR timer_create (2),
134 .BR timer_delete (2),
135 .BR timer_settime (2),