TIMER_GETOVERRUN(3)        POSIX Programmer's Manual       TIMER_GETOVERRUN(3)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.


NNAAMMEE
       timer_getoverrun, timer_gettime, timer_settime -- per-process timers

SSYYNNOOPPSSIISS
       #include <time.h>

       int timer_getoverrun(timer_t _t_i_m_e_r_i_d);
       int timer_gettime(timer_t _t_i_m_e_r_i_d, struct itimerspec *_v_a_l_u_e);
       int timer_settime(timer_t _t_i_m_e_r_i_d, int _f_l_a_g_s,
           const struct itimerspec *restrict _v_a_l_u_e,
           struct itimerspec *restrict _o_v_a_l_u_e);

DDEESSCCRRIIPPTTIIOONN
       The _t_i_m_e_r___g_e_t_t_i_m_e() function shall store the amount of time until the
       specified timer, _t_i_m_e_r_i_d, expires and the reload value of the timer
       into the space pointed to by the _v_a_l_u_e argument. The _i_t___v_a_l_u_e member of
       this structure shall contain the amount of time before the timer
       expires, or zero if the timer is disarmed. This value is returned as
       the interval until timer expiration, even if the timer was armed with
       absolute time. The _i_t___i_n_t_e_r_v_a_l member of _v_a_l_u_e shall contain the reload
       value last set by _t_i_m_e_r___s_e_t_t_i_m_e().

       The _t_i_m_e_r___s_e_t_t_i_m_e() function shall set the time until the next
       expiration of the timer specified by _t_i_m_e_r_i_d from the _i_t___v_a_l_u_e member
       of the _v_a_l_u_e argument and arm the timer if the _i_t___v_a_l_u_e member of _v_a_l_u_e
       is non-zero. If the specified timer was already armed when
       _t_i_m_e_r___s_e_t_t_i_m_e() is called, this call shall reset the time until next
       expiration to the _v_a_l_u_e specified. If the _i_t___v_a_l_u_e member of _v_a_l_u_e is
       zero, the timer shall be disarmed. The effect of disarming or resetting
       a timer with pending expiration notifications is unspecified.

       If the flag TIMER_ABSTIME is not set in the argument _f_l_a_g_s,
       _t_i_m_e_r___s_e_t_t_i_m_e() shall behave as if the time until next expiration is
       set to be equal to the interval specified by the _i_t___v_a_l_u_e member of
       _v_a_l_u_e.  That is, the timer shall expire in _i_t___v_a_l_u_e nanoseconds from
       when the call is made. If the flag TIMER_ABSTIME is set in the argument
       _f_l_a_g_s, _t_i_m_e_r___s_e_t_t_i_m_e() shall behave as if the time until next
       expiration is set to be equal to the difference between the absolute
       time specified by the _i_t___v_a_l_u_e member of _v_a_l_u_e and the current value of
       the clock associated with _t_i_m_e_r_i_d.  That is, the timer shall expire
       when the clock reaches the value specified by the _i_t___v_a_l_u_e member of
       _v_a_l_u_e.  If the specified time has already passed, the function shall
       succeed and the expiration notification shall be made.

       The reload value of the timer shall be set to the value specified by
       the _i_t___i_n_t_e_r_v_a_l member of _v_a_l_u_e.  When a timer is armed with a non-zero
       _i_t___i_n_t_e_r_v_a_l, a periodic (or repetitive) timer is specified.

       Time values that are between two consecutive non-negative integer
       multiples of the resolution of the specified timer shall be rounded up
       to the larger multiple of the resolution. Quantization error shall not
       cause the timer to expire earlier than the rounded time value.

       If the argument _o_v_a_l_u_e is not NULL, the _t_i_m_e_r___s_e_t_t_i_m_e() function shall
       store, in the location referenced by _o_v_a_l_u_e, a value representing the
       previous amount of time before the timer would have expired, or zero if
       the timer was disarmed, together with the previous timer reload value.
       Timers shall not expire before their scheduled time.

       Only a single signal shall be queued to the process for a given timer
       at any point in time. When a timer for which a signal is still pending
       expires, no signal shall be queued, and a timer overrun shall occur.
       When a timer expiration signal is delivered to or accepted by a
       process, the _t_i_m_e_r___g_e_t_o_v_e_r_r_u_n() function shall return the timer
       expiration overrun count for the specified timer. The overrun count
       returned contains the number of extra timer expirations that occurred
       between the time the signal was generated (queued) and when it was
       delivered or accepted, up to but not including an implementation-
       defined maximum of {DELAYTIMER_MAX}.  If the number of such extra
       expirations is greater than or equal to {DELAYTIMER_MAX}, then the
       overrun count shall be set to {DELAYTIMER_MAX}.  The value returned by
       _t_i_m_e_r___g_e_t_o_v_e_r_r_u_n() shall apply to the most recent expiration signal
       delivery or acceptance for the timer. If no expiration signal has been
       delivered for the timer, the return value of _t_i_m_e_r___g_e_t_o_v_e_r_r_u_n() is
       unspecified.

RREETTUURRNN VVAALLUUEE
       If the _t_i_m_e_r___g_e_t_o_v_e_r_r_u_n() function succeeds, it shall return the timer
       expiration overrun count as explained above.

       If the _t_i_m_e_r___g_e_t_t_i_m_e() or _t_i_m_e_r___s_e_t_t_i_m_e() functions succeed, a value of
       0 shall be returned.

       If an error occurs for any of these functions, the value -1 shall be
       returned, and _e_r_r_n_o set to indicate the error.

EERRRROORRSS
       The _t_i_m_e_r___s_e_t_t_i_m_e() function shall fail if:

       EEIINNVVAALL A _v_a_l_u_e structure specified a nanosecond value less than zero or
              greater than or equal to 1000 million, and the _i_t___v_a_l_u_e member
              of that structure did not specify zero seconds and nanoseconds.

       These functions may fail if:

       EEIINNVVAALL The _t_i_m_e_r_i_d argument does not correspond to an ID returned by
              _t_i_m_e_r___c_r_e_a_t_e() but not yet deleted by _t_i_m_e_r___d_e_l_e_t_e().

       The _t_i_m_e_r___s_e_t_t_i_m_e() function may fail if:

       EEIINNVVAALL The _i_t___i_n_t_e_r_v_a_l member of _v_a_l_u_e is not zero and the timer was
              created with notification by creation of a new thread
              (_s_i_g_e_v___s_i_g_e_v___n_o_t_i_f_y was SIGEV_THREAD) and a fixed stack address
              has been set in the thread attribute pointed to by
              _s_i_g_e_v___n_o_t_i_f_y___a_t_t_r_i_b_u_t_e_s.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

EEXXAAMMPPLLEESS
       None.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       Using fixed stack addresses is problematic when timer expiration is
       signaled by the creation of a new thread. Since it cannot be assumed
       that the thread created for one expiration is finished before the next
       expiration of the timer, it could happen that two threads use the same
       memory as a stack at the same time. This is invalid and produces
       undefined results.

RRAATTIIOONNAALLEE
       Practical clocks tick at a finite rate, with rates of 100 hertz and
       1000 hertz being common. The inverse of this tick rate is the clock
       resolution, also called the clock granularity, which in either case is
       expressed as a time duration, being 10 milliseconds and 1 millisecond
       respectively for these common rates. The granularity of practical
       clocks implies that if one reads a given clock twice in rapid
       succession, one may get the same time value twice; and that timers must
       wait for the next clock tick after the theoretical expiration time, to
       ensure that a timer never returns too soon. Note also that the
       granularity of the clock may be significantly coarser than the
       resolution of the data format used to set and get time and interval
       values. Also note that some implementations may choose to adjust time
       and/or interval values to exactly match the ticks of the underlying
       clock.

       This volume of POSIX.1-2008 defines functions that allow an application
       to determine the implementation-supported resolution for the clocks and
       requires an implementation to document the resolution supported for
       timers and _n_a_n_o_s_l_e_e_p() if they differ from the supported clock
       resolution. This is more of a procurement issue than a runtime
       application issue.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _c_l_o_c_k___g_e_t_r_e_s(), _t_i_m_e_r___c_r_e_a_t_e()

       The Base Definitions volume of POSIX.1-2008, <<ttiimmee..hh>>

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
       -- Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, Copyright (C) 2013 by the Institute of
       Electrical and Electronics Engineers, Inc and The Open Group.  (This is
       POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
       event of any discrepancy between this version and the original IEEE and
       The Open Group Standard, the original IEEE and The Open Group Standard
       is the referee document. The original Standard can be obtained online
       at http://www.unix.org/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2013                  TIMER_GETOVERRUN(3)
