Super User's BSD Cross Reference: /FreeBSD/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 .\" $FreeBSD$
29 .\"
30 .Dd July 15, 2016
31 .Dt TIMER_CREATE 2
32 .Os
33 .Sh NAME
34 .Nm timer_create
35 .Nd "create a per-process timer (REALTIME)"
36 .Sh LIBRARY
37 .Lb librt
38 .Sh SYNOPSIS
39 .In time.h
40 .In signal.h
41 .Ft int
42 .Fo timer_create
43 .Fa "clockid_t clockid" "struct sigevent *restrict evp"
44 .Fa "timer_t *restrict timerid"
45 .Fc
46 .Sh DESCRIPTION
47The
48 .Fn timer_create
49system call creates a per-process timer using the specified clock,
50 .Fa clock_id ,
51as the timing base.
52The
53 .Fn timer_create
54system call returns, in the location referenced by
55 .Fa timerid ,
56a timer ID of type
57 .Vt timer_t
58used to identify the timer in timer requests.
59This timer ID is unique within the calling process until the timer is deleted.
60The particular clock,
61 .Fa clock_id ,
62is defined in
63 .In time.h .
64The timer whose ID is returned is in a disarmed state upon return from
65 .Fn timer_create .
66 .Pp
67The
68 .Fa evp
69argument, if
70 .Pf non- Dv NULL ,
71points to a
72 .Vt sigevent
73structure.
74This structure,
75allocated by the application, defines the asynchronous notification to occur
76when the timer expires.
77 .Pp
78If
79 .Fa evp->sigev_notify
80is
81 .Dv SIGEV_SIGNO
82or
83 .Dv SIGEV_THREAD_ID ,
84the signal specified in
85 .Fa evp->sigev_signo
86will be sent to the calling process
87 .Pq Dv SIGEV_SIGNO
88or to the thread whose LWP ID is
89 .Fa evp->sigev_notify_thread_id
90 .Pq Dv SIGEV_THREAD_ID .
91The information for the queued signal will include:
92 .Bl -column ".Va si_value"
93 .It Sy Member Ta Sy Value
94 .It Va si_code Ta Dv SI_TIMER
95 .It Va si_value Ta
96the value stored in
97 .Fa evp->sigev_value
98 .It Va si_timerid Ta timer ID
99 .It Va si_overrun Ta timer overrun count
100 .It Va si_errno Ta
101If timer overrun is
102 .Brq Dv DELAYTIMER_MAX ,
103an error code defined in
104 .In errno.h
105 .El
106 .Pp
107If the
108 .Fa evp
109argument is
110 .Dv NULL ,
111the effect is as if the
112 .Fa evp
113argument pointed to a
114 .Vt sigevent
115structure with the
116 .Va sigev_notify
117member having the value
118 .Dv SIGEV_SIGNAL ,
119the
120 .Va sigev_signo
121having a default signal number
122 .Pq Dv SIGALRM ,
123and the
124 .Va sigev_value
125member having
126the value of the timer ID.
127 .Pp
128This implementation supports a
129 .Fa clock_id
130of
131 .Dv CLOCK_REALTIME
132or
133 .Dv CLOCK_MONOTONIC .
134 .Pp
135If
136 .Fa evp->sigev_notify
137is
138 .Dv SIGEV_THREAD
139and
140 .Fa sev->sigev_notify_attributes
141is not
142 .Dv NULL ,
143if the attribute pointed to by
144 .Fa sev->sigev_notify_attributes
145has
146a thread stack address specified by a call to
147 .Fn pthread_attr_setstack
148or
149 .Fn pthread_attr_setstackaddr ,
150the results are unspecified if the signal is generated more than once.
151 .Sh RETURN VALUES
152If the call succeeds,
153 .Fn timer_create
154returns zero and updates the location referenced by
155 .Fa timerid
156to a
157 .Vt timer_t ,
158which can be passed to the per-process timer calls.
159If an error
160occurs, the system call returns a value of \-1
161and the global variable
162 .Va errno
163is set to indicate the
164error.
165The value of
166 .Fa timerid
167is undefined if an error occurs.
168 .Sh ERRORS
169The
170 .Fn timer_create
171system call
172will fail if:
173 .Bl -tag -width Er
174 .It Bq Er EAGAIN
175The calling process has already created all of the timers it is allowed by
176this implementation.
177 .It Bq Er EINVAL
178The specified clock ID is not supported.
179 .It Bq Er EINVAL
180The specified asynchronous notification method is not supported.
181 .It Bq Er EFAULT
182Any arguments point outside the allocated address space or there is a
183memory protection fault.
184 .El
185 .Sh SEE ALSO
186 .Xr clock_getres 2 ,
187 .Xr timer_delete 2 ,
188 .Xr timer_getoverrun 2 ,
189 .Xr sigevent 3 ,
190 .Xr siginfo 3
191 .Sh STANDARDS
192The
193 .Fn timer_create
194system call conforms to
195 .St -p1003.1-2004 .
196 .Sh HISTORY
197Support for
198 .Tn POSIX
199per-process timer first appeared in
200 .Fx 7.0 .
201 

AltStyle によって変換されたページ (->オリジナル) /