]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/sys/timer_create.2
zfs: merge openzfs/zfs@a03ebd9be
[FreeBSD/FreeBSD.git] / lib / libc / sys / timer_create.2
1 .\" Copyright (c) 2005 David Xu <davidxu@FreeBSD.org>
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice(s), this list of conditions and the following disclaimer as
9 .\"    the first lines of this file unmodified other than the possible
10 .\"    addition of one or more copyright notices.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\"    notice(s), this list of conditions and the following disclaimer in
13 .\"    the documentation and/or other materials provided with the
14 .\"    distribution.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
17 .\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 .\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
20 .\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 .\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 .\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 .\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 .\"
28 .Dd July 15, 2016
29 .Dt TIMER_CREATE 2
30 .Os
31 .Sh NAME
32 .Nm timer_create
33 .Nd "create a per-process timer (REALTIME)"
34 .Sh LIBRARY
35 .Lb librt
36 .Sh SYNOPSIS
37 .In time.h
38 .In signal.h
39 .Ft int
40 .Fo timer_create
41 .Fa "clockid_t clockid" "struct sigevent *restrict evp"
42 .Fa "timer_t *restrict timerid"
43 .Fc
44 .Sh DESCRIPTION
45 The
46 .Fn timer_create
47 system call creates a per-process timer using the specified clock,
48 .Fa clock_id ,
49 as the timing base.
50 The
51 .Fn timer_create
52 system call returns, in the location referenced by
53 .Fa timerid ,
54 a timer ID of type
55 .Vt timer_t
56 used to identify the timer in timer requests.
57 This timer ID is unique within the calling process until the timer is deleted.
58 The particular clock,
59 .Fa clock_id ,
60 is defined in
61 .In time.h .
62 The timer whose ID is returned is in a disarmed state upon return from
63 .Fn timer_create .
64 .Pp
65 The
66 .Fa evp
67 argument, if
68 .Pf non- Dv NULL ,
69 points to a
70 .Vt sigevent
71 structure.
72 This structure,
73 allocated by the application, defines the asynchronous notification to occur
74 when the timer expires.
75 .Pp
76 If
77 .Fa evp->sigev_notify
78 is
79 .Dv SIGEV_SIGNO
80 or
81 .Dv SIGEV_THREAD_ID ,
82 the signal specified in
83 .Fa evp->sigev_signo
84 will be sent to the calling process
85 .Pq Dv SIGEV_SIGNO
86 or to the thread whose LWP ID is
87 .Fa evp->sigev_notify_thread_id
88 .Pq Dv SIGEV_THREAD_ID .
89 The information for the queued signal will include:
90 .Bl -column ".Va si_value"
91 .It Sy Member Ta Sy Value
92 .It Va si_code Ta Dv SI_TIMER
93 .It Va si_value Ta
94 the value stored in
95 .Fa evp->sigev_value
96 .It Va si_timerid Ta timer ID
97 .It Va si_overrun Ta timer overrun count
98 .It Va si_errno Ta
99 If timer overrun is
100 .Brq Dv DELAYTIMER_MAX ,
101 an error code defined in
102 .In errno.h
103 .El
104 .Pp
105 If the
106 .Fa evp
107 argument is
108 .Dv NULL ,
109 the effect is as if the
110 .Fa evp
111 argument pointed to a
112 .Vt sigevent
113 structure with the
114 .Va sigev_notify
115 member having the value
116 .Dv SIGEV_SIGNAL ,
117 the
118 .Va sigev_signo
119 having a default signal number
120 .Pq Dv SIGALRM ,
121 and the
122 .Va sigev_value
123 member having
124 the value of the timer ID.
125 .Pp
126 This implementation supports a
127 .Fa clock_id
128 of
129 .Dv CLOCK_REALTIME
130 or
131 .Dv CLOCK_MONOTONIC .
132 .Pp
133 If
134 .Fa evp->sigev_notify
135 is
136 .Dv SIGEV_THREAD
137 and
138 .Fa sev->sigev_notify_attributes
139 is not
140 .Dv NULL ,
141 if the attribute pointed to by
142 .Fa sev->sigev_notify_attributes
143 has
144 a thread stack address specified by a call to
145 .Fn pthread_attr_setstack
146 or
147 .Fn pthread_attr_setstackaddr ,
148 the results are unspecified if the signal is generated more than once.
149 .Sh RETURN VALUES
150 If the call succeeds,
151 .Fn timer_create
152 returns zero and updates the location referenced by
153 .Fa timerid
154 to a
155 .Vt timer_t ,
156 which can be passed to the per-process timer calls.
157 If an error
158 occurs, the system call returns a value of \-1
159 and the global variable
160 .Va errno
161 is set to indicate the
162 error.
163 The value of
164 .Fa timerid
165 is undefined if an error occurs.
166 .Sh ERRORS
167 The
168 .Fn timer_create
169 system call
170 will fail if:
171 .Bl -tag -width Er
172 .It Bq Er EAGAIN
173 The calling process has already created all of the timers it is allowed by
174 this implementation.
175 .It Bq Er EINVAL
176 The specified clock ID is not supported.
177 .It Bq Er EINVAL
178 The specified asynchronous notification method is not supported.
179 .It Bq Er EFAULT
180 Any arguments point outside the allocated address space or there is a
181 memory protection fault.
182 .El
183 .Sh SEE ALSO
184 .Xr clock_getres 2 ,
185 .Xr timer_delete 2 ,
186 .Xr timer_getoverrun 2 ,
187 .Xr sigevent 3 ,
188 .Xr siginfo 3
189 .Sh STANDARDS
190 The
191 .Fn timer_create
192 system call conforms to
193 .St -p1003.1-2004 .
194 .Sh HISTORY
195 Support for
196 .Tn POSIX
197 per-process timer first appeared in
198 .Fx 7.0 .