Commit | Line | Data |
---|---|---|
88b3ccf2 KB |
1 | .\" Copyright (c) 1983 The Regents of the University of California. |
2 | .\" All rights reserved. | |
616f8a75 | 3 | .\" |
88b3ccf2 KB |
4 | .\" Redistribution and use in source and binary forms are permitted |
5 | .\" provided that the above copyright notice and this paragraph are | |
6 | .\" duplicated in all such forms and that any documentation, | |
7 | .\" advertising materials, and other materials related to such | |
8 | .\" distribution and use acknowledge that the software was developed | |
9 | .\" by the University of California, Berkeley. The name of the | |
10 | .\" University may not be used to endorse or promote products derived | |
11 | .\" from this software without specific prior written permission. | |
12 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
13 | .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
14 | .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
15 | .\" | |
16 | .\" @(#)getitimer.2 6.4 (Berkeley) %G% | |
616f8a75 | 17 | .\" |
1d87bb13 | 18 | .TH GETITIMER 2 "" |
616f8a75 KM |
19 | .UC 5 |
20 | .SH NAME | |
21 | getitimer, setitimer \- get/set value of interval timer | |
22 | .SH SYNOPSIS | |
23 | .nf | |
24 | .ft B | |
25 | #include <sys/time.h> | |
26 | .PP | |
27 | .ft B | |
28 | #define ITIMER_REAL 0 /* real time intervals */ | |
29 | #define ITIMER_VIRTUAL 1 /* virtual time intervals */ | |
30 | #define ITIMER_PROF 2 /* user and system virtual time */ | |
31 | .sp | |
32 | .ft B | |
33 | getitimer(which, value) | |
34 | int which; | |
35 | struct itimerval *value; | |
36 | .PP | |
37 | .ft B | |
38 | setitimer(which, value, ovalue) | |
39 | int which; | |
40 | struct itimerval *value, *ovalue; | |
41 | .fi | |
42 | .SH DESCRIPTION | |
43 | The system provides each process with three interval timers, | |
44 | defined in | |
45 | .RI < sys/time.h >. | |
46 | The | |
47 | .I getitimer | |
48 | call returns the current value for the timer specified in | |
1d87bb13 KM |
49 | .I which |
50 | in the structure at | |
51 | .IR value . | |
52 | The | |
616f8a75 | 53 | .I setitimer |
1d87bb13 KM |
54 | call sets a timer to the specified |
55 | .I value | |
56 | (returning the previous value of the timer if | |
57 | .I ovalue | |
58 | is nonzero). | |
616f8a75 KM |
59 | .PP |
60 | A timer value is defined by the | |
61 | .I itimerval | |
62 | structure: | |
63 | .PP | |
64 | .nf | |
65 | .RS | |
66 | .DT | |
67 | struct itimerval { | |
68 | struct timeval it_interval; /* timer interval */ | |
69 | struct timeval it_value; /* current value */ | |
70 | }; | |
71 | .RE | |
72 | .fi | |
73 | .PP | |
74 | If | |
75 | .I it_value | |
76 | is non-zero, it indicates the time to the next timer expiration. | |
77 | If | |
78 | .I it_interval | |
79 | is non-zero, it specifies a value to be used in reloading | |
80 | .I it_value | |
81 | when the timer expires. | |
82 | Setting | |
83 | .I it_value | |
84 | to 0 disables a timer. Setting | |
85 | .I it_interval | |
86 | to 0 causes a timer to be disabled after its next expiration (assuming | |
87 | .I it_value | |
88 | is non-zero). | |
89 | .PP | |
90 | Time values smaller than the resolution of the | |
91 | system clock are rounded up to this resolution | |
1d87bb13 | 92 | (on the VAX, 10 milliseconds). |
616f8a75 KM |
93 | .PP |
94 | The ITIMER_REAL timer decrements in real time. A SIGALRM signal is | |
95 | delivered when this timer expires. | |
96 | .PP | |
97 | The ITIMER_VIRTUAL timer decrements in process virtual time. | |
98 | It runs only when the process is executing. A SIGVTALRM signal | |
99 | is delivered when it expires. | |
100 | .PP | |
101 | The ITIMER_PROF timer decrements both in process virtual time and | |
102 | when the system is running on behalf of the process. It is designed | |
103 | to be used by interpreters in statistically profiling the execution | |
104 | of interpreted programs. | |
105 | Each time the ITIMER_PROF timer expires, the SIGPROF signal is | |
106 | delivered. Because this signal may interrupt in-progress | |
107 | system calls, programs using this timer must be prepared to | |
108 | restart interrupted system calls. | |
109 | .SH NOTES | |
110 | Three macros for manipulating time values are defined in | |
111 | .RI < sys/time.h >. | |
112 | .I Timerclear | |
113 | sets a time value to zero, | |
114 | .I timerisset | |
115 | tests if a time value is non-zero, and | |
116 | .I timercmp | |
117 | compares two time values (beware that >= and <= do not | |
118 | work with this macro). | |
119 | .SH "RETURN VALUE | |
120 | If the calls succeed, a value of 0 is returned. If an error occurs, | |
121 | the value \-1 is returned, and a more precise error code is placed | |
122 | in the global variable \fIerrno\fP. | |
123 | .SH "ERRORS | |
124 | The possible errors are: | |
125 | .TP 15 | |
126 | [EFAULT] | |
fd690c8b | 127 | The \fIvalue\fP parameter specified a bad address. |
616f8a75 KM |
128 | .TP 15 |
129 | [EINVAL] | |
fd690c8b | 130 | A \fIvalue\fP parameter specified a time was too large |
616f8a75 KM |
131 | to be handled. |
132 | .SH "SEE ALSO" | |
d0528fe6 | 133 | select(2), sigvec(2), gettimeofday(2) |