]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/timer_getoverrun.2
isatty.3: Most non-tty files nowadays result in the error ENOTTY
[thirdparty/man-pages.git] / man2 / timer_getoverrun.2
CommitLineData
c6f51a12
MK
1.\" Copyright (c) 2009 Linux Foundation, written by Michael Kerrisk
2.\" <mtk.manpages@gmail.com>
3.\"
93015253 4.\" %%%LICENSE_START(VERBATIM)
c6f51a12
MK
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.
4b72fb64 24.\" %%%LICENSE_END
4784c377 25.\"
4b8c67d9 26.TH TIMER_GETOVERRUN 2 2017-09-15 Linux "Linux Programmer's Manual"
c6f51a12
MK
27.SH NAME
28timer_getoverrun \- get overrun count for a POSIX per-process timer
29.SH SYNOPSIS
30.nf
31.B #include <time.h>
dbfe9c70 32.PP
c6f51a12
MK
33.BI "int timer_getoverrun(timer_t " timerid );
34.fi
dbfe9c70 35.PP
702cbe15 36Link with \fI\-lrt\fP.
68e4db0a 37.PP
c6f51a12
MK
38.in -4n
39Feature Test Macro Requirements for glibc (see
40.BR feature_test_macros (7)):
41.in
68e4db0a 42.PP
c6f51a12 43.BR timer_getoverrun ():
98dbe7af 44_POSIX_C_SOURCE\ >=\ 199309L
c6f51a12
MK
45.SH DESCRIPTION
46.BR timer_getoverrun ()
47returns the "overrun count" for the timer referred to by
48.IR timerid .
49An application can use the overrun count to accurately calculate the number
50of timer expirations that would have occurred over a given time interval.
51Timer overruns can occur both when receiving expiration notifications
52via signals
53.RB ( SIGEV_SIGNAL ),
54and via threads
55.RB ( SIGEV_THREAD ).
efeece04 56.PP
c6f51a12
MK
57When expiration notifications are delivered via a signal,
58overruns can occur as follows.
59Regardless of whether or not a real-time signal is used for
60timer notifications,
61the system queues at most one signal per timer.
d8c2f63f 62(This is the behavior specified by POSIX.1.
c6f51a12
MK
63The alternative, queuing one signal for each timer expiration,
64could easily result in overflowing the allowed limits for
65queued signals on the system.)
66Because of system scheduling delays,
67or because the signal may be temporarily blocked,
68there can be a delay between the time when the notification
69signal is generated and the time when it
70is delivered (e.g., caught by a signal handler) or accepted (e.g., using
71.BR sigwaitinfo (2)).
72In this interval, further timer expirations may occur.
73The timer overrun count is the number of additional
74timer expirations that occurred between the time when the signal
75was generated and when it was delivered or accepted.
efeece04 76.PP
c6f51a12
MK
77Timer overruns can also occur when expiration notifications
78are delivered via invocation of a thread,
79since there may be an arbitrary delay between an expiration of the timer
80and the invocation of the notification thread,
a6753832 81and in that delay interval, additional timer expirations may occur.
c6f51a12
MK
82.SH RETURN VALUE
83On success,
84.BR timer_getoverrun ()
85returns the overrun count of the specified timer;
86this count may be 0 if no overruns have occurred.
87On failure, \-1 is returned, and
88.I errno
89is set to indicate the error.
90.SH ERRORS
91.TP
92.B EINVAL
93.I timerid
94is not a valid timer ID.
95.SH VERSIONS
96This system call is available since Linux 2.6.
97.SH CONFORMING TO
d8c2f63f 98POSIX.1-2001, POSIX.1-2008.
c6f51a12
MK
99.SH NOTES
100When timer notifications are delivered via signals
101.RB ( SIGEV_SIGNAL ),
102on Linux it is also possible to obtain the overrun count via the
103.I si_overrun
104field of the
105.I siginfo_t
106structure (see
107.BR sigaction (2)).
108This allows an application to avoid the overhead of making
109a system call to obtain the overrun count,
d8c2f63f 110but is a nonportable extension to POSIX.1.
efeece04 111.PP
d8c2f63f 112POSIX.1 discusses timer overruns only in the context of
c6f51a12
MK
113timer notifications using signals.
114.\" FIXME . Austin bug filed, 11 Feb 09
115.SH BUGS
d8c2f63f 116POSIX.1 specifies that if the timer overrun count
c6f51a12
MK
117is equal to or greater than an implementation-defined maximum,
118.BR DELAYTIMER_MAX ,
119then
120.BR timer_getoverrun ()
121should return
122.BR DELAYTIMER_MAX .
123However, Linux does not implement this feature: instead,
124if the timer overrun value exceeds the maximum representable integer,
125the counter cycles, starting once more from low values.
126.\" Bug filed: http://bugzilla.kernel.org/show_bug.cgi?id=12665
127.\" http://thread.gmane.org/gmane.linux.kernel/113276/
d34ba634
MK
128.SH EXAMPLE
129See
130.BR timer_create (2).
c6f51a12
MK
131.SH SEE ALSO
132.BR clock_gettime (2),
133.BR sigaction (2),
134.BR signalfd (2),
135.BR sigwaitinfo (2),
136.BR timer_create (2),
137.BR timer_delete (2),
138.BR timer_settime (2),
139.BR signal (7),
140.BR time (7)