2 .\" This file and its contents are supplied under the terms of the
3 .\" Common Development and Distribution License ("CDDL"), version 1.0.
4 .\" You may only use this file in accordance with the terms of version
7 .\" A full copy of the text of the CDDL should have accompanied this
8 .\" source. A copy of the CDDL is also available via the Internet at
9 .\" http://www.illumos.org/license/CDDL.
12 .\" Copyright (c) 2015, Joyent, Inc. All Rights Reserved.
21 .Nd create and manipulate timers via a file descriptor interface
33 .Fa "const struct itimerspec *restrict value"
34 .Fa "struct itimterspec *restrict ovalue"
39 .Fa "struct itimerspec *value"
42 These routines create and manipulate timers in which events are associated
43 with a file descriptor, allowing for timer-based events to be used
44 in file-descriptor based facilities like
51 function creates a timer with the clock
58 clock types, as defined in
64 may be used as an alias for
65 .Sy CLOCK_HIGHRES Ns .)
69 argument specifies additional parameters for the timer instance, and can have
70 any of the following values:
74 Instance will be closed upon an
83 Instance will be set to be non-blocking. A
87 instance that has been initialized with
91 in lieu of blocking if the
92 timer has not expired since the last
99 The following operations can be performed upon a
105 Atomically reads and clears the number of timer expirations since the
109 .Fn timerfd_settime .
111 the number of expirations will be copied into the eight byte buffer
112 passed to the system call. If there have been no expirations of the
113 timer since the last successful
118 will block until at least the next expiration,
121 if the instance was created with
123 Note that if multiple threads are blocked in
125 for the same timer, only one of them will return upon
126 a single timer expiration.
128 If the buffer specified to
131 eight bytes in length,
135 .It Sy poll(2), port_get(3C), epoll_wait(3C)
137 Provide notification when the timer expires or has expired in the past without
140 Note that threads being simultaneously
145 (or equivalents) for the same
146 timer constitute an application-level race; on a timer expiration,
147 the thread blocked in
149 may or may not return depending on how
150 it is scheduled with respect to the thread blocked in
153 .It Sy timerfd_gettime()
155 Returns the amount of time until the next timer expiration, with the
156 same functional signature and semantics as
157 .Xr timer_gettime 3C .
159 .It Sy timerfd_settime()
161 Sets or disarms the timer, with the
162 same functional signature and semantics as
163 .Xr timer_settime 3C .
167 Upon succesful completion, a file descriptor associated with the instance
168 is returned. Otherwise,
170 is returned and errno is set to indicate the error.
174 function will fail if:
182 .Pf { Sy OPEN_MAX Ns }
183 file descriptors open in the calling process.
190 .Pf { Sy PRIV_PROC_CLOCK_HIGHRES Ns }
191 is not asserted in the effective set of the calling process.
197 .Xr timer_create 3C ,
198 .Xr timer_gettime 3C ,
199 .Xr timer_settime 3C ,