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