xref: /netbsd-src/lib/libc/sys/timer_settime.2 (revision 23c8222edbfb0f0932d88a8351d3a0cf817dfb9e)
1.\"	$NetBSD: timer_settime.2,v 1.4 2003/09/14 09:02:50 wiz Exp $
2.\"
3.\" Copyright (c) 2003 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Christos Zoulas.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\" 3. All advertising materials mentioning features or use of this software
18.\"    must display the following acknowledgement:
19.\"        This product includes software developed by the NetBSD
20.\"        Foundation, Inc. and its contributors.
21.\" 4. Neither the name of The NetBSD Foundation nor the names of its
22.\"    contributors may be used to endorse or promote products derived
23.\"    from this software without specific prior written permission.
24.\"
25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35.\" POSSIBILITY OF SUCH DAMAGE.
36.\"
37.Dd September 13, 2003
38.Dt TIMER_SETTIME 2
39.Os
40.Sh NAME
41.Nm timer_settime ,
42.Nm timer_gettime ,
43.Nm timer_getoverrun
44.Nd process timer manipulation
45.Sh LIBRARY
46.Lb libc
47.Sh SYNOPSIS
48.In time.h
49.Ft int
50.Fn timer_settime "timer_t timerid" "int flags" "const struct itimerspec * restrict tim" "struct itimerspec * restrict otim"
51.Ft int
52.Fn timer_gettime "timer_t timerid" "struct itimerspec *tim"
53.Ft int
54.Fn timer_getoverrun "timer_t timerid"
55.Sh DESCRIPTION
56The
57.Fn timer_settime
58sets the next expiration time of the timer with id
59.Ar timerid
60to the
61.Fa it_value
62specified in the
63.Ar tim
64argument.
65If the value is 0, the timer is disarmed.
66If the argument
67.Ar otim
68is not
69.Dv NULL
70the old timer settingas are returned.
71If the
72.Ar flags
73argument is set to
74.Dv TIMER_RELTIME
75then the expiration time is set to the value in nanoseconds specified
76in the
77.Ar tim
78argument from the time the call to
79.Fn timer_settime
80was made.
81If the
82.Ar flags
83argument is set to
84.Dv TIMER_ABSTIME
85then the expiration time is set to be equal to the difference between the
86clock associated with this timer, and the value specified in the
87.Ar tim
88argument.
89If that time has already passed, then the call succeeds, and the
90expiration notification occurs.
91.Pp
92If the
93.Fa it_interval
94of the
95.Ar tim
96argument is non-zero, then the timer reloads upon expiration.
97.Pp
98The
99.Fn timer_gettime
100function returns the current settings of the timer
101specified by the
102.Ar timerid
103argument in the
104.Ar tim
105argument.
106.Pp
107Only one notification event (signal) can be pending for a given timer
108and process.
109If a timer expires while the signal is still queued for delivery, then
110the overrun counter for that timer is increased.
111The counter can store values up to
112.Dv DELAYTIMER_MAX .
113When the signal is finally delivered to the process, then the
114.Fn timer_getoverrun
115function can be used to retrieve the overrun counter for the timer
116specified in the
117.Ar timerid
118argument.
119.Sh NOTES
120Expiration time values are always rounded up to the resolution of the timer,
121so a notification will never be sent before the requested time.
122Values returned in the
123.Ar otim
124argument of
125.Fn timer_settime
126or in the
127.Ar tim
128argment of
129.Fn timer_gettime
130are subject to the above rounding effect and might not exactly match the
131requested values by the user.
132.Sh RETURN VALUES
133If successful, the
134.Fn timer_gettime
135and
136.Fn timer_settime
137functions return 0, and the
138.Fn timer_getoverrun
139function returns the expiration overrun count for the specified timer.
140Otherwise, the functions return \-1, and set
141.Dv errno
142to indicate the error.
143.Sh ERRORS
144The
145.Fn timer_gettime ,
146.Fn timer_getoverrun ,
147and
148.Fn timer_settime
149functions will fail if:
150.Bl -tag -width Er
151.It Bq Er EINVAL
152The argument
153.Ar timerid
154does not correspond to a valid timer id as returned by
155.Fn timer_create
156or that timer id has been deleted by
157.Fn timer_delete .
158.El
159.Pp
160The
161.Fn timer_settime
162function will fail if:
163.Bl -tag -width Er
164.It Bq Er EINVAL
165A nanosecond field in the
166.Ar tim
167structure specified a value less than zero or greater than or equal to 10e9.
168.El
169.Sh SEE ALSO
170.Xr clock_gettime 2 ,
171.Xr timer_create 2 ,
172.Xr timer_delete 2
173.Sh STANDARDS
174.St -p1003.1b-93 ,
175.St -p1003.1i-95
176