1TIMER_GETOVERRUN(2)        Linux Programmer's Manual       TIMER_GETOVERRUN(2)
2
3
4

NAME

6       timer_getoverrun - get overrun count for a POSIX per-process timer
7

SYNOPSIS

9       #include <time.h>
10
11       int timer_getoverrun(timer_t timerid);
12
13       Link with -lrt.
14
15   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
16
17       timer_getoverrun():
18           _POSIX_C_SOURCE >= 199309L
19

DESCRIPTION

21       timer_getoverrun()  returns  the "overrun count" for the timer referred
22       to by timerid.  An application can use the overrun count to  accurately
23       calculate the number of timer expirations that would have occurred over
24       a given time interval.  Timer overruns can occur  both  when  receiving
25       expiration  notifications  via  signals (SIGEV_SIGNAL), and via threads
26       (SIGEV_THREAD).
27
28       When expiration notifications are delivered via a signal, overruns  can
29       occur  as  follows.  Regardless of whether or not a real-time signal is
30       used for timer notifications, the system queues at most one signal  per
31       timer.   (This  is the behavior specified by POSIX.1.  The alternative,
32       queuing one signal for each timer expiration, could  easily  result  in
33       overflowing  the allowed limits for queued signals on the system.)  Be‐
34       cause of system scheduling delays, or because the signal may be  tempo‐
35       rarily  blocked, there can be a delay between the time when the notifi‐
36       cation signal is generated and the time when  it  is  delivered  (e.g.,
37       caught  by  a signal handler) or accepted (e.g., using sigwaitinfo(2)).
38       In this interval, further timer expirations may occur.  The timer over‐
39       run  count  is the number of additional timer expirations that occurred
40       between the time when the signal was generated and when it  was  deliv‐
41       ered or accepted.
42
43       Timer  overruns can also occur when expiration notifications are deliv‐
44       ered via invocation of a thread, since there may be an arbitrary  delay
45       between  an expiration of the timer and the invocation of the notifica‐
46       tion thread, and in that delay interval, additional  timer  expirations
47       may occur.
48

RETURN VALUE

50       On  success, timer_getoverrun() returns the overrun count of the speci‐
51       fied timer; this count may be 0 if no overruns have occurred.  On fail‐
52       ure, -1 is returned, and errno is set to indicate the error.
53

ERRORS

55       EINVAL timerid is not a valid timer ID.
56

VERSIONS

58       This system call is available since Linux 2.6.
59

CONFORMING TO

61       POSIX.1-2001, POSIX.1-2008.
62

NOTES

64       When  timer  notifications are delivered via signals (SIGEV_SIGNAL), on
65       Linux it is also possible to obtain the overrun count via the  si_over‐
66       run  field  of the siginfo_t structure (see sigaction(2)).  This allows
67       an application to avoid the overhead of making a system call to  obtain
68       the overrun count, but is a nonportable extension to POSIX.1.
69
70       POSIX.1 discusses timer overruns only in the context of timer notifica‐
71       tions using signals.
72

BUGS

74       POSIX.1 specifies that if the  timer  overrun  count  is  equal  to  or
75       greater  than  an  implementation-defined maximum, DELAYTIMER_MAX, then
76       timer_getoverrun() should return DELAYTIMER_MAX.  However, before Linux
77       4.19,  if the timer overrun value exceeds the maximum representable in‐
78       teger, the counter cycles, starting once more from low  values.   Since
79       Linux  4.19,  timer_getoverrun()  returns  DELAYTIMER_MAX  (defined  as
80       INT_MAX in <limits.h>) in this case (and the overrun value is reset  to
81       0).
82

EXAMPLES

84       See timer_create(2).
85

SEE ALSO

87       clock_gettime(2), sigaction(2), signalfd(2), sigwaitinfo(2), timer_cre‐
88       ate(2), timer_delete(2), timer_settime(2), signal(7), time(7)
89

COLOPHON

91       This page is part of release 5.13 of the Linux  man-pages  project.   A
92       description  of  the project, information about reporting bugs, and the
93       latest    version    of    this    page,    can     be     found     at
94       https://www.kernel.org/doc/man-pages/.
95
96
97
98Linux                             2021-03-22               TIMER_GETOVERRUN(2)
Impressum