getitimer.2 (2010 09)

g
getitimer(2) getitimer(2)
ITIMER_THREAD_VIRTUAL
Decrements in thread virtual time. This timer runs only when the
thread is executing. A
SIGVTALRM signal is delivered to the
thread which set this timer when the timer expires.
ITIMER_THREAD_PROF
Decrements both in thread virtual time and when the system is
running on behalf of the thread. Each time the
ITIMER_THREAD_PROF
timer expires, a SIGPROF signal is
delivered to the thread which set this timer.
Since a
SIGPROF signal can interrupt in-progress system calls, programs using this timer must be
prepared to restart the interrupted system call.
Interval timers are not inherited by a child process across a
fork(), but are inherited across an
exec().
Three macros for manipulating time values are defined in
<sys/time.h>:
timerclear Set a time value to zero.
timerisset Test if a time value is non-zero.
timercmp Compare two time values. (Beware that >=
and <= do not work with the
timercmp macro.)
The timer used with
ITIMER_REAL is also used by alarm() (see alarm (2)). Thus successive calls to
alarm(), getitimer(), and setitimer() set and return the state of a single timer. In addition, a
call to alarm() sets the timer interval to zero.
The interaction between
setitimer() and any of alarm(), sleep() or usleep() is unspecified.
RETURN VALUE
Upon successful completion,
getitimer() or setitimer() returns 0. Otherwise, 1 is returned and
errno is set to indicate the error.
ERRORS
The
setitimer() function will fail if:
[EINVAL] The value argument is not in canonical form. (In canonical form, the number of
microseconds is a non-negative integer less than 1,000,000 and the number of
seconds is a non-negative integer.)
The
getitimer() and setitimer() functions may fail if:
[EINVAL] The which argument is not recognized.
[EFAULT] The value structure specified a bad address. Reliable detection of this error is
implementation dependent.
EXAMPLES
The following call to
setitimer() sets the real-time interval timer to expire initially after 10 seconds
and every 0.5 seconds thereafter:
struct itimerval rttimer;
struct itimerval old_rttimer;
rttimer.it_value.tv_sec = 10;
rttimer.it_value.tv_usec = 0;
rttimer.it_interval.tv_sec = 0;
rttimer.it_interval.tv_usec = 500000;
setitimer (ITIMER_REAL, &rttimer, &old_rttimer);
AUTHOR
getitimer() was developed by the University of California, Berkeley.
SEE ALSO
alarm(2), exec(2), ualarm(2), usleep(2), pthread_attr_setscope(3T), pthread_create(3T),
pthread_sigmask(3T), sleep(3C), signal(5).
2 Hewlett-Packard Company 2 HP-UX 11i Version 3: September 2010