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.
88 instance that has been initialized with
92 in lieu of blocking if the
93 timer has not expired since the last
100 The following operations can be performed upon a
106 Atomically reads and clears the number of timer expirations since the
110 .Fn timerfd_settime .
112 the number of expirations will be copied into the eight byte buffer
113 passed to the system call.
114 If there have been no expirations of the timer since the last successful
119 will block until at least the next expiration,
122 if the instance was created with
124 Note that if multiple threads are blocked in
126 for the same timer, only one of them will return upon
127 a single timer expiration.
129 If the buffer specified to
132 eight bytes in length,
136 .It Sy poll(2), port_get(3C), epoll_wait(3C)
138 Provide notification when the timer expires or has expired in the past without
141 Note that threads being simultaneously
146 (or equivalents) for the same
147 timer constitute an application-level race; on a timer expiration,
148 the thread blocked in
150 may or may not return depending on how
151 it is scheduled with respect to the thread blocked in
154 .It Sy timerfd_gettime()
156 Returns the amount of time until the next timer expiration, with the
157 same functional signature and semantics as
158 .Xr timer_gettime 3C .
160 .It Sy timerfd_settime()
162 Sets or disarms the timer, with the
163 same functional signature and semantics as
164 .Xr timer_settime 3C .
168 Upon successful completion, a file descriptor associated with the instance
172 is returned and errno is set to indicate the error.
176 function will fail if:
184 .Pf { Sy OPEN_MAX Ns }
185 file descriptors open in the calling process.
192 .Pf { Sy PRIV_PROC_CLOCK_HIGHRES Ns }
193 is not asserted in the effective set of the calling process.
199 .Xr timer_create 3C ,
200 .Xr timer_gettime 3C ,
201 .Xr timer_settime 3C ,