1GETITIMER(2)                  System Calls Manual                 GETITIMER(2)
2
3
4

NAME

6       getitimer, setitimer - get/set value of interval timer
7

SYNOPSIS

9       #include <sys/time.h>
10
11       #define ITIMER_REAL      0    /* real time intervals */
12       #define ITIMER_VIRTUAL   1    /* virtual time intervals */
13       #define ITIMER_PROF      2    /* user and system virtual time */
14
15       getitimer(which, value)
16       int which;
17       struct itimerval *value;
18
19       setitimer(which, value, ovalue)
20       int which;
21       struct itimerval *value, *ovalue;
22

DESCRIPTION

24       The system provides each process with three interval timers, defined in
25       <sys/time.h>.  The getitimer call returns the  current  value  for  the
26       timer specified in which in the structure at value.  The setitimer call
27       sets a timer to the specified value (returning the  previous  value  of
28       the timer if ovalue is nonzero).
29
30       A timer value is defined by the itimerval structure:
31
32              struct itimerval {
33                   struct    timeval it_interval;     /* timer interval */
34                   struct    timeval it_value;   /* current value */
35              };
36
37       If  it_value is non-zero, it indicates the time to the next timer expi‐
38       ration.  If it_interval is non-zero, it specifies a value to be used in
39       reloading  it_value when the timer expires.  Setting it_value to 0 dis‐
40       ables a timer.  Setting it_interval to 0 causes a timer to be  disabled
41       after its next expiration (assuming it_value is non-zero).
42
43       Time values smaller than the resolution of the system clock are rounded
44       up to this resolution (on the VAX, 10 milliseconds).
45
46       The ITIMER_REAL timer decrements in real time.   A  SIGALRM  signal  is
47       delivered when this timer expires.
48
49       The  ITIMER_VIRTUAL  timer decrements in process virtual time.  It runs
50       only when the process is executing.  A SIGVTALRM  signal  is  delivered
51       when it expires.
52
53       The  ITIMER_PROF timer decrements both in process virtual time and when
54       the system is running on behalf of the process.  It is designed  to  be
55       used by interpreters in statistically profiling the execution of inter‐
56       preted programs.  Each time the ITIMER_PROF timer expires, the  SIGPROF
57       signal  is  delivered.   Because  this signal may interrupt in-progress
58       system calls, programs using this timer must  be  prepared  to  restart
59       interrupted system calls.
60

NOTES

62       Three  macros for manipulating time values are defined in <sys/time.h>.
63       Timerclear sets a time value to zero, timerisset tests if a time  value
64       is  non-zero, and timercmp compares two time values (beware that >= and
65       <= do not work with this macro).
66

NOTES (PDP-11)

68       On the PDP-11, setitimer rounds timer values up to seconds  resolution.
69       (This  saves some space and computation in the overburdened PDP-11 ker‐
70       nel.)
71

RETURN VALUE

73       If the calls succeed, a value of 0 is returned.  If  an  error  occurs,
74       the  value  -1  is returned, and a more precise error code is placed in
75       the global variable errno.
76

ERRORS

78       The possible errors are:
79
80       [EFAULT]       The value parameter specified a bad address.
81
82       [EINVAL]       A value parameter specified a time was too large  to  be
83                      handled.
84

SEE ALSO

86       sigvec(2), gettimeofday(2)
87
88
89
904.2 Berkeley Distribution       August 26, 1985                   GETITIMER(2)
Impressum