1 .\" $NetBSD: getitimer.2,v 1.24 2010/04/30 04:17:45 jruoho Exp $
3 .\" Copyright (c) 1983, 1991, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the University nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" @(#)getitimer.2 8.3 (Berkeley) 5/16/95
38 .Nd get/set value of interval timer
43 .Fd #define ITIMER_REAL 0
44 .Fd #define ITIMER_VIRTUAL 1
45 .Fd #define ITIMER_PROF 2
47 .Fn getitimer "int which" "struct itimerval *value"
49 .Fn setitimer "int which" "const struct itimerval * restrict value" "struct itimerval * restrict ovalue"
51 The system provides each process with three interval timers,
53 .Ao Pa sys/time.h Ac .
56 call returns the current value for the timer specified in
62 call sets a timer to the specified
64 (returning the previous value of the timer if
68 A timer value is defined by the
71 .Bd -literal -offset indent
73 struct timeval it_interval; /* timer interval */
74 struct timeval it_value; /* current value */
80 is non-zero, it indicates the time to the next timer expiration.
83 is non-zero, it specifies a value to be used in reloading
85 when the timer expires.
88 to 0 disables a timer.
91 to 0 causes a timer to be disabled after its next expiration (assuming
95 Time values smaller than the resolution of the
96 system clock are rounded up to this resolution
97 (typically 10 milliseconds).
101 timer decrements in real time.
105 delivered when this timer expires.
109 timer decrements in process virtual time.
110 It runs only when the process is executing.
114 is delivered when it expires.
118 timer decrements both in process virtual time and
119 when the system is running on behalf of the process.
120 It is designed to be used by interpreters in statistically profiling
121 the execution of interpreted programs.
128 Because this signal may interrupt in-progress
129 system calls, programs using this timer must be prepared to
130 restart interrupted system calls.
132 Macros for manipulating time values are defined in the
136 sets a time value to zero,
138 tests if a time value is non-zero,
140 compares two time values,
142 adds a time value to another time value,
144 computes the time difference between two time values.
145 For additional details, see
148 If the calls succeed, a value of 0 is returned.
149 If an error occurs, the value \-1 is returned, and a more precise error
150 code is placed in the global variable
161 parameter specified a bad address.
165 parameter specified a time that was too large
182 revision however marked both functions as obsolescent,
183 recommending the use of
191 function call appeared in