2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group. In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document. The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
25 .\" This notice shall appear on any product containing this material.
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
43 .\" Copyright 1989 AT&T
44 .\" Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
45 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
47 .TH TIMER_CREATE 3C "Sep 15, 2015"
49 timer_create \- create a timer
56 \fBint\fR \fBtimer_create\fR(\fBclockid_t\fR \fIclock_id\fR,
57 \fBstruct sigevent *restrict\fR \fIevp\fR, \fBtimer_t *restrict\fR \fItimerid\fR);
62 The \fBtimer_create()\fR function creates a timer using the specified clock,
63 \fIclock_id\fR, as the timing base. The \fBtimer_create()\fR function returns,
64 in the location referenced by \fItimerid\fR, a timer \fBID\fR of type
65 \fBtimer_t\fR used to identify the timer in timer requests. This timer \fBID\fR
66 will be unique within the calling process until the timer is deleted. The
67 particular clock, \fIclock_id\fR, is defined in <\fBtime.h\fR>. The timer whose
68 \fBID\fR is returned will be in a disarmed state upon return from
69 \fBtimer_create()\fR, and can be started using \fBtimer_settime\fR(3C).
71 The \fIevp\fR argument, if non-null, points to a \fBsigevent\fR structure. This
72 structure, allocated by the application, defines the asynchronous notification
73 that will occur when the timer expires (see \fBsignal.h\fR(3HEAD) for event
74 notification details). If the \fIevp\fR argument is \fINULL\fR, the effect is
75 as if the \fIevp\fR argument pointed to a \fBsigevent\fR structure with the
76 \fBsigev_notify\fR member having the value \fBSIGEV_SIGNAL\fR, the
77 \fBsigev_signo\fR having the value \fBSIGALRM\fR, and the \fBsigev_value\fR
78 member having the value of the timer \fBID\fR.
80 The system defines a set of clocks that can be used as timing bases for
81 per-process timers. The following values for \fIclock_id\fR are supported:
85 \fB\fBCLOCK_REALTIME\fR\fR
94 \fB\fBCLOCK_VIRTUAL\fR\fR
103 \fB\fBCLOCK_PROF\fR\fR
106 user and system CPU usage clock
112 \fB\fBCLOCK_HIGHRES\fR\fR
115 non-adjustable, high-resolution clock
120 For timers created with a \fIclock_id\fR of \fBCLOCK_HIGHRES\fR, the system
121 will attempt to use an optimal hardware source. This may include, but is not
122 limited to, per-CPU timer sources. The actual hardware source used is
123 transparent to the user and may change over the lifetime of the timer. For
124 example, if the caller that created the timer were to change its processor
125 binding or its processor set, the system may elect to drive the timer with a
126 hardware source that better reflects the new binding. Timers based on a
127 \fIclock_id\fR of \fBCLOCK_HIGHRES\fR are ideally suited for interval timers
128 that have minimal jitter tolerance.
130 Timers are not inherited by a child process across a \fBfork\fR(2) and are
131 disarmed and deleted by a call to one of the \fBexec\fR functions (see
135 Upon successful completion, \fBtimer_create()\fR returns \fB0\fR and updates
136 the location referenced by \fItimerid\fR to a \fBtimer_t\fR, which can be
137 passed to the per-process timer calls. If an error occurs, the function returns
138 \fB\(mi1\fR and sets \fBerrno\fR to indicate the error. The value of
139 \fItimerid\fR is undefined if an error occurs.
142 The \fBtimer_create()\fR function will fail if:
149 The system lacks sufficient signal queuing resources to honor the request, or
150 the calling process has already created all of the timers it is allowed by the
160 The specified clock \fBID\fR, \fIclock_id\fR, is not defined.
169 The specified clock \fBID\fR, \fIclock_id\fR, is \fBCLOCK_HIGHRES\fR and the
170 {\fBPRIV_PROC_CLOCK_HIGHRES\fR} is not asserted in the effective set of the
176 See \fBattributes\fR(5) for descriptions of the following attributes:
184 ATTRIBUTE TYPE ATTRIBUTE VALUE
186 Interface Stability Committed
188 MT-Level MT-Safe with exceptions
190 Standard See \fBstandards\fR(5).
195 \fBexec\fR(2), \fBfork\fR(2), \fBtime\fR(2), \fBclock_settime\fR(3C),
196 \fBsignal\fR(3C), \fBsignal.h\fR(3HEAD), \fBtimer_delete\fR(3C),
197 \fBtimer_settime\fR(3C), \fBattributes\fR(5), \fBprivileges\fR(5),