
GETITIMER(2)               UNIX Programmer's Manual               GETITIMER(2)

NNAAMMEE
     ggeettiittiimmeerr, sseettiittiimmeerr - get/set value of interval timer

SSYYNNOOPPSSIISS
     ##iinncclluuddee <<ssyyss//ttiimmee..hh>>
     ##ddeeffiinnee IITTIIMMEERR__RREEAALL      00
     ##ddeeffiinnee IITTIIMMEERR__VVIIRRTTUUAALL   11
     ##ddeeffiinnee IITTIIMMEERR__PPRROOFF      22

     _i_n_t
     ggeettiittiimmeerr(_i_n_t _w_h_i_c_h, _s_t_r_u_c_t _i_t_i_m_e_r_v_a_l _*_v_a_l_u_e)

     _i_n_t
     sseettiittiimmeerr(_i_n_t _w_h_i_c_h, _s_t_r_u_c_t _i_t_i_m_e_r_v_a_l _*_v_a_l_u_e, _s_t_r_u_c_t _i_t_i_m_e_r_v_a_l _*_o_v_a_l_u_e)

DDEESSCCRRIIPPTTIIOONN
     The system provides each process with three interval timers, defined in
     <_s_y_s_/_t_i_m_e_._h>. The ggeettiittiimmeerr() call returns the current value for the
     timer specified in _w_h_i_c_h in the structure at _v_a_l_u_e. The sseettiittiimmeerr() call
     sets a timer to the specified _v_a_l_u_e (returning the previous value of the
     timer if _o_v_a_l_u_e is non-nil).

     A timer value is defined by the _i_t_i_m_e_r_v_a_l structure:

           struct itimerval {
                   struct  timeval it_interval;    /* timer interval */
                   struct  timeval it_value;       /* current value */
           };

     If _i_t___v_a_l_u_e is non-zero, it indicates the time to the next timer expira-
     tion.  If _i_t___i_n_t_e_r_v_a_l is non-zero, it specifies a value to be used in
     reloading _i_t___v_a_l_u_e when the timer expires.  Setting _i_t___v_a_l_u_e to 0 dis-
     ables a timer.  Setting _i_t___i_n_t_e_r_v_a_l to 0 causes a timer to be disabled
     after its next expiration (assuming _i_t___v_a_l_u_e is non-zero).

     Time values smaller than the resolution of the system clock are rounded
     up to this resolution (typically 10 milliseconds).

     The ITIMER_REAL timer decrements in real time.  A SIGALRM signal is de-
     livered when this timer expires.

     The ITIMER_VIRTUAL timer decrements in process virtual time.  It runs on-
     ly when the process is executing.  A SIGVTALRM signal is delivered when
     it expires.

     The ITIMER_PROF timer decrements both in process virtual time and when
     the system is running on behalf of the process.  It is designed to be
     used by interpreters in statistically profiling the execution of inter-
     preted programs.  Each time the ITIMER_PROF timer expires, the SIGPROF
     signal is delivered.  Because this signal may interrupt in-progress sys-
     tem calls, programs using this timer must be prepared to restart inter-
     rupted system calls.

NNOOTTEESS
     Three macros for manipulating time values are defined in <_s_y_s_/_t_i_m_e_._h>.
     _T_i_m_e_r_c_l_e_a_r sets a time value to zero, _t_i_m_e_r_i_s_s_e_t tests if a time value is
     non-zero, and _t_i_m_e_r_c_m_p compares two time values (beware that >= and <= do
     not work with this macro).

RREETTUURRNN VVAALLUUEESS
     If the calls succeed, a value of 0 is returned.  If an error occurs, the
     value -1 is returned, and a more precise error code is placed in the
     global variable _e_r_r_n_o.

EERRRROORRSS
     GGeettiittiimmeerr() and sseettiittiimmeerr() will fail if:

     [EFAULT]      The _v_a_l_u_e parameter specified a bad address.

     [EINVAL]      A _v_a_l_u_e parameter specified a time was too large to be han-
                   dled.

SSEEEE AALLSSOO
     select(2),  sigvec(2),  gettimeofday(2)

HHIISSTTOORRYY
     The ggeettiittiimmeerr function call appeared in 4.2BSD.

4.2 Berkeley Distribution       March 10, 1991                               2


















































