]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/timer_getoverrun.2
execve.2, fallocate.2, futex.2, sched_rr_get_interval.2, select_tut.2, shmget.2,...
[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 .\" 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.
7 .\"
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.
12 .\"
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
19 .\" professionally.
20 .\"
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"
24 .SH NAME
25 timer_getoverrun \- get overrun count for a POSIX per-process timer
26 .SH SYNOPSIS
27 .nf
28 .B #include <time.h>
29
30 .BI "int timer_getoverrun(timer_t " timerid );
31 .fi
32
33 Link with \fI\-lrt\fP.
34 .sp
35 .in -4n
36 Feature Test Macro Requirements for glibc (see
37 .BR feature_test_macros (7)):
38 .in
39 .sp
40 .BR timer_getoverrun ():
41 _POSIX_C_SOURCE >= 199309
42 .SH DESCRIPTION
43 .BR timer_getoverrun ()
44 returns the "overrun count" for the timer referred to by
45 .IR timerid .
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
49 via signals
50 .RB ( SIGEV_SIGNAL ),
51 and via threads
52 .RB ( SIGEV_THREAD ).
53
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
57 timer notifications,
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
68 .BR sigwaitinfo (2)).
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.
73
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
79 .SH RETURN VALUE
80 On success,
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
85 .I errno
86 is set to indicate the error.
87 .SH ERRORS
88 .TP
89 .B EINVAL
90 .I timerid
91 is not a valid timer ID.
92 .SH VERSIONS
93 This system call is available since Linux 2.6.
94 .SH CONFORMING TO
95 POSIX.1-2001
96 .SH NOTES
97 When timer notifications are delivered via signals
98 .RB ( SIGEV_SIGNAL ),
99 on Linux it is also possible to obtain the overrun count via the
100 .I si_overrun
101 field of the
102 .I siginfo_t
103 structure (see
104 .BR sigaction (2)).
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.
108
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
112 .SH BUGS
113 POSIX.1-2001 specifies that if the timer overrun count
114 is equal to or greater than an implementation-defined maximum,
115 .BR DELAYTIMER_MAX ,
116 then
117 .BR timer_getoverrun ()
118 should return
119 .BR DELAYTIMER_MAX .
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/
125 .SH EXAMPLE
126 See
127 .BR timer_create (2).
128 .SH SEE ALSO
129 .BR clock_gettime (2),
130 .BR sigaction (2),
131 .BR signalfd (2),
132 .BR sigwaitinfo (2),
133 .BR timer_create (2),
134 .BR timer_delete (2),
135 .BR timer_settime (2),
136 .BR signal (7),
137 .BR time (7)