]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - lib/libc/sys/timer_create.2
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.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 .\" $FreeBSD$
29 .\"
30 .Dd January 12, 2009
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
47 The
48 .Fn timer_create
49 system call creates a per-process timer using the specified clock,
50 .Fa clock_id ,
51 as the timing base.
52 The
53 .Fn timer_create
54 system call returns, in the location referenced by
55 .Fa timerid ,
56 a timer ID of type
57 .Vt timer_t
58 used to identify the timer in timer requests.
59 This timer ID is unique within the calling process until the timer is deleted.
60 The particular clock,
61 .Fa clock_id ,
62 is defined in
63 .In time.h .
64 The timer whose ID is returned is in a disarmed state upon return from
65 .Fn timer_create .
66 .Pp
67 The
68 .Fa evp
69 argument, if
70 .Pf non- Dv NULL ,
71 points to a
72 .Vt sigevent
73 structure.
74 This structure,
75 allocated by the application, defines the asynchronous notification to occur
76 when the timer expires.
77 If the
78 .Fa evp
79 argument is
80 .Dv NULL ,
81 the effect is as if the
82 .Fa evp
83 argument pointed to a
84 .Vt sigevent
85 structure with the
86 .Va sigev_notify
87 member having the value
88 .Dv SIGEV_SIGNAL ,
89 the
90 .Va sigev_signo
91 having a default signal number, and the
92 .Va sigev_value
93 member having
94 the value of the timer ID.
95 .Pp
96 The implementations supports a
97 .Fa clock_id
98 of
99 .Dv CLOCK_REALTIME
100 or
101 .Dv CLOCK_MONOTONIC .
102 .Pp
103 If
104 .Fa evp->sigev_notify
105 is
106 .Dv SIGEV_THREAD
107 and
108 .Fa sev->sigev_notify_attributes
109 is not
110 .Dv NULL ,
111 if the attribute pointed to by
112 .Fa sev->sigev_notify_attributes
113 has
114 a thread stack address specified by a call to
115 .Fn pthread_attr_setstack
116 or
117 .Fn pthread_attr_setstackaddr ,
118 the results are unspecified if the signal is generated more than once.
119 .Sh RETURN VALUES
120 If the call succeeds,
121 .Fn timer_create
122 returns zero and updates the location referenced by
123 .Fa timerid
124 to a
125 .Vt timer_t ,
126 which can be passed to the per-process timer calls.
127 If an error
128 occurs, the system call returns a value of \-1
129 and the global variable
130 .Va errno
131 is set to indicate the
132 error.
133 The value of
134 .Fa timerid
135 is undefined if an error occurs.
136 .Sh ERRORS
137 The
138 .Fn timer_create
139 system call
140 will fail if:
141 .Bl -tag -width Er
142 .It Bq Er EAGAIN
143 The calling process has already created all of the timers it is allowed by
144 this implementation.
145 .It Bq Er EINVAL
146 The specified clock ID is not supported.
147 .It Bq Er EFAULT
148 Any arguments point outside the allocated address space or there is a
149 memory protection fault.
150 .El
151 .Sh SEE ALSO
152 .Xr clock_getres 2 ,
153 .Xr timer_delete 2 ,
154 .Xr timer_getoverrun 2 ,
155 .Xr siginfo 3
156 .Sh STANDARDS
157 The
158 .Fn timer_create
159 system call conforms to
160 .St -p1003.1-2004 .
161 .Sh HISTORY
162 Support for
163 .Tn POSIX
164 per-process timer first appeared in
165 .Fx 7.0 .