GETITIMER(2) COMMAND REFERENCE GETITIMER(2)
NAME
getitimer, setitimer - get/set value of interval timer
SYNOPSIS
#include <sys/time.h>
getitimer(which, value)
int which;
struct itimerval *value;
setitimer(which, value, ovalue)
int which;
struct itimerval *value, *ovalue;
DESCRIPTION
The system provides each process with three interval timers,
defined in <sys/time.h>:
#define ITIMER_REAL 0 /* real time intervals */
#define ITIMER_VIRTUAL 1 /* virtual time intervals */
#define ITIMER_PROF 2 /* user and system virtual time */
The getitimer call returns in value the current value for
the timer specified in which. The setitimer call sets the
value of the timer specified in which to value, returning
the previous value of the timer in ovalue.
A timer value is defined by the itimerval structure, defined
in <sys/time.h>:
struct itimerval {
struct timeval it_interval; /* timer interval */
struct timeval it_value; /* current value */
};
The timeval structure, defined in <sys/time.h>, is:
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* and microseconds */
}
For getitimer, if it_value is non-zero, it indicates the
time to the next timer expiration. For example, if it_value
is set to 30 seconds, then in 30 seconds the timer will
expire and a SIGALRM signal will be sent to the process. If
it_interval is non-zero, it specifies a value to be used in
reloading it_value when the timer expires.
For setitimer, setting it_value to non-zero sets the time to
the next timer expiration. Setting it_interval to non-zero
specifies the value to be used in reloading it_value when
Printed 4/6/89 1
GETITIMER(2) COMMAND REFERENCE GETITIMER(2)
the timer expires. Setting it_value to 0 disables a timer.
Setting it_interval to 0 causes a timer to be disabled after
its next expiration (assuming it_value is non-zero).
Time values smaller than the resolution of the system clock
are rounded up to this resolution.
The ITIMER_REAL timer decrements in real time. A SIGALRM
signal is delivered when this timer expires.
The ITIMER_VIRTUAL timer decrements in process virtual time.
It runs only 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 interpreted
programs. Each time the ITIMER_PROF timer expires, the
SIGPROF signal is delivered. Because this signal may
interrupt in-progress system calls, programs using this
timer must be prepared to restart interrupted system calls.
Three macros for manipulating time values are defined in
<sys/time.h>. Timerclear sets a time value to zero,
timerisset tests if a time value is non-zero, and timercmp
compares two time values (beware that >= and <= do not work
with this macro).
DIAGNOSTICS
Getitimer and setitimer will fail if one or more of the
following are true:
[EFAULT] The value parameter specifies a bad address.
[EINVAL] Which is an invalid argument.
Setitimer will also fail if the following is true:
[EINVAL] The value parameter specifies an invalid time.
This could mean that either the seconds or
microseconds field of the timeval structure is
negative, or the seconds field is greater than
100000000 (over 3 years), or if the
microseconds field is greater than 1000000 (1
sec).
RETURN VALUE
Upon successful completion, a value of 0 is returned.
Otherwise, a value of -1 is returned and errno is set to
indicate the error.
Printed 4/6/89 2
GETITIMER(2) COMMAND REFERENCE GETITIMER(2)
SEE ALSO
gettimeofday(2) and sigvec(2).
Printed 4/6/89 3
%%index%%
na:360,106;
sy:466,1696;
de:2162,2283;4877,1459;
di:6336,1078;
rv:7414,280;
se:8126,205;
%%index%%000000000122