summaryrefslogtreecommitdiffstats
path: root/man3p/getitimer.3p
blob: d1446f32a6b26eaf56eb1f8f93e50660e967f132 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
.TH "GETITIMER" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" getitimer 
.SH NAME
getitimer, setitimer \- get and set value of interval timer
.SH SYNOPSIS
.LP
\fB#include <sys/time.h>
.br
.sp
int getitimer(int\fP \fIwhich\fP\fB, struct itimerval *\fP\fIvalue\fP\fB);
.br
int setitimer(int\fP \fIwhich\fP\fB, const struct itimerval *restrict\fP
\fIvalue\fP\fB,
.br
\ \ \ \ \ \  struct itimerval *restrict\fP \fIovalue\fP\fB); \fP
\fB
.br
\fP
.SH DESCRIPTION
.LP
The \fIgetitimer\fP() function shall store the current value of the
timer specified by \fIwhich\fP into the structure pointed
to by \fIvalue\fP. The \fIsetitimer\fP() function shall set the timer
specified by \fIwhich\fP to the value specified in the
structure pointed to by \fIvalue\fP, and if \fIovalue\fP is not a
null pointer, store the previous value of the timer in the
structure pointed to by \fIovalue\fP.
.LP
A timer value is defined by the \fBitimerval\fP structure, specified
in \fI<sys/time.h>\fP. If \fIit_value\fP is non-zero, it shall indicate
the time to the next
timer expiration. If \fIit_interval\fP is non-zero, it shall specify
a value to be used in reloading \fIit_value\fP when the
timer expires. Setting \fIit_value\fP to 0 shall disable a timer,
regardless of the value of \fIit_interval\fP. Setting
\fIit_interval\fP to 0 shall disable a timer after its next expiration
(assuming \fIit_value\fP is non-zero).
.LP
Implementations may place limitations on the granularity of timer
values. For each interval timer, if the requested timer value
requires a finer granularity than the implementation supports, the
actual timer value shall be rounded up to the next supported
value.
.LP
An XSI-conforming implementation provides each process with at least
three interval timers, which are indicated by the
\fIwhich\fP argument:
.TP 7
ITIMER_REAL
Decrements in real time. A SIGALRM signal is delivered when this timer
expires.
.TP 7
ITIMER_VIRTUAL
Decrements in process virtual time. It runs only when the process
is executing. A SIGVTALRM signal is delivered when it
expires.
.TP 7
ITIMER_PROF
Decrements both in process virtual time and when the system is running
on behalf of the process. It is designed to be used by
interpreters in statistically profiling the execution of interpreted
programs. Each time the ITIMER_PROF timer expires, the SIGPROF
signal is delivered.
.sp
.LP
The interaction between \fIsetitimer\fP() and any of \fIalarm\fP(),
\fIsleep\fP(), or \fIusleep\fP() is unspecified.
.SH RETURN VALUE
.LP
Upon successful completion, \fIgetitimer\fP() or \fIsetitimer\fP()
shall return 0; otherwise, -1 shall be returned and
\fIerrno\fP set to indicate the error.
.SH ERRORS
.LP
The \fIsetitimer\fP() function shall fail if:
.TP 7
.B EINVAL
The \fIvalue\fP argument is not in canonical form. (In canonical form,
the number of microseconds is a non-negative integer
less than 1000000 and the number of seconds is a non-negative integer.)
.sp
.LP
The \fIgetitimer\fP() and \fIsetitimer\fP() functions may fail if:
.TP 7
.B EINVAL
The \fIwhich\fP argument is not recognized.
.sp
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIalarm\fP() , \fIsleep\fP() , \fItimer_getoverrun\fP() , \fIualarm\fP()
, \fIusleep\fP() , the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
\fI<signal.h>\fP, \fI<sys/time.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .