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