getitimer(3C) getitimer(3C)
NAME
getitimer, setitimer - get/set value of interval timer
SYNOPSIS
#include <sys/time.h>
int getitimer(int which, struct itimerval *value);
int setitimer(int which, struct itimerval *value,
struct itimerval *ovalue);
DESCRIPTION
The system provides each process with three interval timers, defined
in sys/time.h. The getitimer() call stores the current value of the
timer specified by which into the structure pointed to by value. The
setitimer() call sets the value of the timer specified by which to the
value specified in the structure pointed to by value, and if ovalue is
not NULL, stores the previous value of the timer in the structure
pointed to by ovalue.
A timer value is defined by the itimerval structure (see
gettimeofday(3C) for the definition of timeval), which includes the
following members:
struct timeval itinterval; /* timer interval */
struct timeval itvalue; /* current value */
If itvalue is non-zero, it indicates the time to the next timer
expiration. If itinterval is non-zero, it specifies a value to be
used in reloading itvalue when the timer expires. Setting itvalue to
zero disables a timer, regardless of the value of itinterval. Setting
itinterval to zero disables a timer after its next expiration (assum-
ing itvalue is non-zero).
Time values smaller than the resolution of the system clock are
rounded up to this resolution.
The three timers are:
ITIMERREAL Decrements in real time. A SIGALRM signal is delivered
when this timer expires.
ITIMERVIRTUAL Decrements in process virtual time (user mode). It runs
only when the process is executing. A SIGVTALRM signal
is delivered when it expires.
Page 1 Reliant UNIX 5.44 Printed 11/98
getitimer(3C) getitimer(3C)
ITIMERPROF Decrements both in process virtual time and when the
system is running on behalf of the process (user and
system mode). It is designed to be used by interpreters
in statistically profiling the execution of interpreted
programs. Each time the ITIMERPROF 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.
The interaction between setitimer() and any of alarm(), sleep() or
usleep() is unspecified.
RESULT
If the calls succeed, a value of 0 is returned. If an error occurs,
the value -1 is returned, and an error code is placed in the global
variable errno.
Under the following conditions, the functions getitimer() and
setitimer() fail and set errno to:
EINVAL The specified number of seconds is greater than 100,000,000,
the number of microseconds is greater than or equal to
1,000,000, or the which parameter is unrecognized.
NOTES
The microseconds field should not be equal to or greater than one
second.
setitimer() is independent of the alarm system call.
Do not use setitimer() with the sleep routine. A sleep following a
setitimer() wipes out knowledge of the user signal handler.
SEE ALSO
alarm(2), usleep(3), gettimeofday(3C), sleep(3C), sleep(3C-ucb), sig-
nal(5), systime(5), time(5).
Page 2 Reliant UNIX 5.44 Printed 11/98