table of contents
other versions
- wheezy 3.44-1
- jessie 3.74-1
- jessie-backports 4.10-2~bpo8+1
- testing 4.10-2
- unstable 4.10-2
other sections
GETITIMER(2) | Linux Programmer's Manual | GETITIMER(2) |
NAME¶
getitimer, setitimer - get or set value of an interval timerSYNOPSIS¶
#include <sys/time.h>int getitimer(int which, struct itimerval *curr_value);int setitimer(int which, const struct itimerval *new_value, struct itimerval *old_value);
DESCRIPTION¶
The system provides each process with three interval timers, each decrementing in a distinct time domain. When any timer expires, a signal is sent to the process, and the timer (potentially) restarts.- ITIMER_REAL
- decrements in real time, and delivers SIGALRM upon expiration.
- ITIMER_VIRTUAL
- decrements only when the process is executing, and delivers SIGVTALRM upon expiration.
- ITIMER_PROF
- decrements both when the process executes and when the system is executing on behalf of the process. Coupled with ITIMER_VIRTUAL, this timer is usually used to profile the time spent by the application in user and kernel space. SIGPROF is delivered upon expiration.
struct itimerval { struct timeval it_interval; /* next value */ struct timeval it_value; /* current value */ }; struct timeval { time_t tv_sec; /* seconds */ suseconds_t tv_usec; /* microseconds */ };
The function getitimer() fills the structure pointed to by curr_value with the current setting for the timer specified by which (one of ITIMER_REAL, ITIMER_VIRTUAL, or ITIMER_PROF). The element it_value is set to the amount of time remaining on the timer, or zero if the timer is disabled. Similarly, it_interval is set to the reset value.
RETURN VALUE¶
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.ERRORS¶
- EFAULT
- new_value, old_value, or curr_value is not valid a pointer.
- EINVAL
- which is not one of ITIMER_REAL, ITIMER_VIRTUAL, or ITIMER_PROF; or (since Linux 2.6.22) one of the tv_usec fields in the structure pointed to by new_value contains a value outside the range 0 to 999999.
CONFORMING TO¶
POSIX.1-2001, SVr4, 4.4BSD (this call first appeared in 4.2BSD). POSIX.1-2008 marks getitimer() and setitimer() obsolete, recommending the use of the POSIX timers API (timer_gettime(2), timer_settime(2), etc.) instead.NOTES¶
A child created via fork(2) does not inherit its parent's interval timers. Interval timers are preserved across an execve(2).setitimer(which, NULL, &old_value);
getitimer(which, &old_value);
BUGS¶
The generation and delivery of a signal are distinct, and only one instance of each of the signals listed above may be pending for a process. Under very heavy loading, an ITIMER_REAL timer may expire before the signal from a previous expiration has been delivered. The second signal in such an event will be lost.SEE ALSO¶
gettimeofday(2), sigaction(2), signal(2), timer_create(2), timerfd_create(2), time(7)COLOPHON¶
This page is part of release 3.44 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/.2012-10-01 | Linux |