[Previous] [Contents] [Next]

getitimer()

Get the value of an interval timer

Synopsis:

#include <sys/time.h>

int getitimer ( int which,
                struct itimerval *value );

Library:

libc

Description:

The system provides each process with four interval timers, defined in <sys/time.h>. The getitimer() function stores the current value of the timer specified by which into the structure pointed to by value.

A timer value is defined by the itimerval structure (see gettimeofday() for the definition of timeval), which includes the following members:

struct timeval    it_interval;    /* timer interval */
struct timeval    it_value;       /* current value */

The it_value member indicates the time to the next timer expiration. The it_interval member specifies a value to be used in reloading it_value when the timer expires. Setting it_value to 0 disables a timer, regardless of the value of it_interval. Setting it_interval to 0 disables a timer after its next expiration (assuming it_value is nonzero).

Time values smaller than the resolution of the system clock are rounded up to the resolution of the system clock.

The four timers are:

ITIMER_REAL
Decrements in real time. A SIGALRM signal is delivered when this timer expires.
ITIMER_VIRTUAL
Decrements in process virtual time. It runs only when the process is executing. A SIGVTALRM signal is delivered when it expires. (For multithreaded programs see the Caveats section below).
ITIMER_PROF
Decrements both in process virtual time and when the system is running on behalf of the process. It's 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 functions, programs using this timer must be prepared to restart interrupted functions. (For multithreaded programs see the Caveats section below).

Returns:

0
Success.
-1
An error occurred; errno is set.

Errors:

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 argument is unrecognized.

Classification:

Standard Unix

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

alarm(), gettimeofday(), pthread_attr_setscope(), pthread_sigmask(), setitimer(), sigprocmask(), sleep(), sysconf()


[Previous] [Contents] [Next]