15507a2aeSRuslan Ermilov.\" Copyright (c) 2005 David Xu <[email protected]> 2b1e515a3SDavid Xu.\" All rights reserved. 3bb5eebe6SDavid Xu.\" 4bb5eebe6SDavid Xu.\" Redistribution and use in source and binary forms, with or without 5bb5eebe6SDavid Xu.\" modification, are permitted provided that the following conditions 6bb5eebe6SDavid Xu.\" are met: 7bb5eebe6SDavid Xu.\" 1. Redistributions of source code must retain the above copyright 8bb5eebe6SDavid Xu.\" notice(s), this list of conditions and the following disclaimer as 9bb5eebe6SDavid Xu.\" the first lines of this file unmodified other than the possible 10bb5eebe6SDavid Xu.\" addition of one or more copyright notices. 11bb5eebe6SDavid Xu.\" 2. Redistributions in binary form must reproduce the above copyright 12bb5eebe6SDavid Xu.\" notice(s), this list of conditions and the following disclaimer in 13bb5eebe6SDavid Xu.\" the documentation and/or other materials provided with the 14bb5eebe6SDavid Xu.\" distribution. 15bb5eebe6SDavid Xu.\" 16bb5eebe6SDavid Xu.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY 17bb5eebe6SDavid Xu.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18bb5eebe6SDavid Xu.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19bb5eebe6SDavid Xu.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE 20bb5eebe6SDavid Xu.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21bb5eebe6SDavid Xu.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22bb5eebe6SDavid Xu.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23bb5eebe6SDavid Xu.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24bb5eebe6SDavid Xu.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25bb5eebe6SDavid Xu.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26bb5eebe6SDavid Xu.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27bb5eebe6SDavid Xu.\" 28bb5eebe6SDavid Xu.\" $FreeBSD$ 29bb5eebe6SDavid Xu.\" 30*463970daSJohn Baldwin.Dd July 15, 2016 31bb5eebe6SDavid Xu.Dt TIMER_CREATE 2 32bb5eebe6SDavid Xu.Os 33bb5eebe6SDavid Xu.Sh NAME 34bb5eebe6SDavid Xu.Nm timer_create 355507a2aeSRuslan Ermilov.Nd "create a per-process timer (REALTIME)" 36bb5eebe6SDavid Xu.Sh LIBRARY 37e9311906SDavid Xu.Lb librt 38bb5eebe6SDavid Xu.Sh SYNOPSIS 39bb5eebe6SDavid Xu.In time.h 40a28d1439SDaniel Gerzo.In signal.h 41bb5eebe6SDavid Xu.Ft int 425507a2aeSRuslan Ermilov.Fo timer_create 435507a2aeSRuslan Ermilov.Fa "clockid_t clockid" "struct sigevent *restrict evp" 445507a2aeSRuslan Ermilov.Fa "timer_t *restrict timerid" 455507a2aeSRuslan Ermilov.Fc 46bb5eebe6SDavid Xu.Sh DESCRIPTION 47bb5eebe6SDavid XuThe 48bb5eebe6SDavid Xu.Fn timer_create 495507a2aeSRuslan Ermilovsystem call creates a per-process timer using the specified clock, 50bb5eebe6SDavid Xu.Fa clock_id , 515507a2aeSRuslan Ermilovas the timing base. 525507a2aeSRuslan ErmilovThe 53bb5eebe6SDavid Xu.Fn timer_create 545507a2aeSRuslan Ermilovsystem call returns, in the location referenced by 55bb5eebe6SDavid Xu.Fa timerid , 565507a2aeSRuslan Ermilova timer ID of type 575507a2aeSRuslan Ermilov.Vt timer_t 585507a2aeSRuslan Ermilovused to identify the timer in timer requests. 59bb5eebe6SDavid XuThis timer ID is unique within the calling process until the timer is deleted. 60bb5eebe6SDavid XuThe particular clock, 61bb5eebe6SDavid Xu.Fa clock_id , 62bb5eebe6SDavid Xuis defined in 63bb5eebe6SDavid Xu.In time.h . 64bb5eebe6SDavid XuThe timer whose ID is returned is in a disarmed state upon return from 65bb5eebe6SDavid Xu.Fn timer_create . 66bb5eebe6SDavid Xu.Pp 67bb5eebe6SDavid XuThe 68bb5eebe6SDavid Xu.Fa evp 695507a2aeSRuslan Ermilovargument, if 705507a2aeSRuslan Ermilov.Pf non- Dv NULL , 715507a2aeSRuslan Ermilovpoints to a 725507a2aeSRuslan Ermilov.Vt sigevent 735507a2aeSRuslan Ermilovstructure. 745507a2aeSRuslan ErmilovThis structure, 75bb5eebe6SDavid Xuallocated by the application, defines the asynchronous notification to occur 765507a2aeSRuslan Ermilovwhen the timer expires. 77*463970daSJohn Baldwin.Pp 78*463970daSJohn BaldwinIf 79*463970daSJohn Baldwin.Fa evp->sigev_notify 80*463970daSJohn Baldwinis 81*463970daSJohn Baldwin.Dv SIGEV_SIGNO 82*463970daSJohn Baldwinor 83*463970daSJohn Baldwin.Dv SIGEV_THREAD_ID , 84*463970daSJohn Baldwinthe signal specified in 85*463970daSJohn Baldwin.Fa evp->sigev_signo 86*463970daSJohn Baldwinwill be sent to the calling process 87*463970daSJohn Baldwin.Pq Dv SIGEV_SIGNO 88*463970daSJohn Baldwinor to the thread whose LWP ID is 89*463970daSJohn Baldwin.Fa evp->sigev_notify_thread_id 90*463970daSJohn Baldwin.Pq Dv SIGEV_THREAD_ID . 91*463970daSJohn BaldwinThe information for the queued signal will include: 92*463970daSJohn Baldwin.Bl -column ".Va si_value" 93*463970daSJohn Baldwin.It Sy Member Ta Sy Value 94*463970daSJohn Baldwin.It Va si_code Ta Dv SI_TIMER 95*463970daSJohn Baldwin.It Va si_value Ta 96*463970daSJohn Baldwinthe value stored in 97*463970daSJohn Baldwin.Fa evp->sigev_value 98*463970daSJohn Baldwin.It Va si_timerid Ta timer ID 99*463970daSJohn Baldwin.It Va si_overrun Ta timer overrun count 100*463970daSJohn Baldwin.It Va si_errno Ta 101*463970daSJohn BaldwinIf timer overrun is 102*463970daSJohn Baldwin.Brq Dv DELAYTIMER_MAX , 103*463970daSJohn Baldwinan error code defined in 104*463970daSJohn Baldwin.In errno.h 105*463970daSJohn Baldwin.El 106*463970daSJohn Baldwin.Pp 1075507a2aeSRuslan ErmilovIf the 108bb5eebe6SDavid Xu.Fa evp 1095507a2aeSRuslan Ermilovargument is 1105507a2aeSRuslan Ermilov.Dv NULL , 1115507a2aeSRuslan Ermilovthe effect is as if the 1125507a2aeSRuslan Ermilov.Fa evp 1135507a2aeSRuslan Ermilovargument pointed to a 1145507a2aeSRuslan Ermilov.Vt sigevent 1155507a2aeSRuslan Ermilovstructure with the 1165507a2aeSRuslan Ermilov.Va sigev_notify 1175507a2aeSRuslan Ermilovmember having the value 1185507a2aeSRuslan Ermilov.Dv SIGEV_SIGNAL , 1195507a2aeSRuslan Ermilovthe 1205507a2aeSRuslan Ermilov.Va sigev_signo 121*463970daSJohn Baldwinhaving a default signal number 122*463970daSJohn Baldwin.Pq Dv SIGALRM , 123*463970daSJohn Baldwinand the 1245507a2aeSRuslan Ermilov.Va sigev_value 1255507a2aeSRuslan Ermilovmember having 126bb5eebe6SDavid Xuthe value of the timer ID. 127bb5eebe6SDavid Xu.Pp 128*463970daSJohn BaldwinThis implementation supports a 1295507a2aeSRuslan Ermilov.Fa clock_id 1305507a2aeSRuslan Ermilovof 1315507a2aeSRuslan Ermilov.Dv CLOCK_REALTIME 1325507a2aeSRuslan Ermilovor 1335507a2aeSRuslan Ermilov.Dv CLOCK_MONOTONIC . 134bb5eebe6SDavid Xu.Pp 1355507a2aeSRuslan ErmilovIf 136a28d1439SDaniel Gerzo.Fa evp->sigev_notify 1375507a2aeSRuslan Ermilovis 1385507a2aeSRuslan Ermilov.Dv SIGEV_THREAD 1395507a2aeSRuslan Ermilovand 1405507a2aeSRuslan Ermilov.Fa sev->sigev_notify_attributes 1415507a2aeSRuslan Ermilovis not 1425507a2aeSRuslan Ermilov.Dv NULL , 1435507a2aeSRuslan Ermilovif the attribute pointed to by 1445507a2aeSRuslan Ermilov.Fa sev->sigev_notify_attributes 1455507a2aeSRuslan Ermilovhas 146bb5eebe6SDavid Xua thread stack address specified by a call to 147bb5eebe6SDavid Xu.Fn pthread_attr_setstack 148bb5eebe6SDavid Xuor 149bb5eebe6SDavid Xu.Fn pthread_attr_setstackaddr , 150bb5eebe6SDavid Xuthe results are unspecified if the signal is generated more than once. 151bb5eebe6SDavid Xu.Sh RETURN VALUES 152bb5eebe6SDavid XuIf the call succeeds, 153bb5eebe6SDavid Xu.Fn timer_create 1545507a2aeSRuslan Ermilovreturns zero and updates the location referenced by 155bb5eebe6SDavid Xu.Fa timerid 1565507a2aeSRuslan Ermilovto a 1575507a2aeSRuslan Ermilov.Vt timer_t , 1585507a2aeSRuslan Ermilovwhich can be passed to the per-process timer calls. 1595507a2aeSRuslan ErmilovIf an error 1605507a2aeSRuslan Ermilovoccurs, the system call returns a value of \-1 1615507a2aeSRuslan Ermilovand the global variable 1625507a2aeSRuslan Ermilov.Va errno 1635507a2aeSRuslan Ermilovis set to indicate the 1645507a2aeSRuslan Ermiloverror. 1655507a2aeSRuslan ErmilovThe value of 1665507a2aeSRuslan Ermilov.Fa timerid 1675507a2aeSRuslan Ermilovis undefined if an error occurs. 168bb5eebe6SDavid Xu.Sh ERRORS 169bb5eebe6SDavid XuThe 170bb5eebe6SDavid Xu.Fn timer_create 1715507a2aeSRuslan Ermilovsystem call 172bb5eebe6SDavid Xuwill fail if: 173bb5eebe6SDavid Xu.Bl -tag -width Er 174bb5eebe6SDavid Xu.It Bq Er EAGAIN 175bb5eebe6SDavid XuThe calling process has already created all of the timers it is allowed by 1765507a2aeSRuslan Ermilovthis implementation. 177bb5eebe6SDavid Xu.It Bq Er EINVAL 178bb5eebe6SDavid XuThe specified clock ID is not supported. 179*463970daSJohn Baldwin.It Bq Er EINVAL 180*463970daSJohn BaldwinThe specified asynchronous notification method is not supported. 181bb5eebe6SDavid Xu.It Bq Er EFAULT 182bb5eebe6SDavid XuAny arguments point outside the allocated address space or there is a 183bb5eebe6SDavid Xumemory protection fault. 184bb5eebe6SDavid Xu.El 185bb5eebe6SDavid Xu.Sh SEE ALSO 186bb5eebe6SDavid Xu.Xr clock_getres 2 , 187bb5eebe6SDavid Xu.Xr timer_delete 2 , 18852f047eeSSergey Kandaurov.Xr timer_getoverrun 2 , 189*463970daSJohn Baldwin.Xr sigevent 3 , 190412295fdSDavid Xu.Xr siginfo 3 191bb5eebe6SDavid Xu.Sh STANDARDS 192bb5eebe6SDavid XuThe 193bb5eebe6SDavid Xu.Fn timer_create 1945507a2aeSRuslan Ermilovsystem call conforms to 1959f63b422SGlen Barber.St -p1003.1-2004 . 1966f59c4c0SDavid Xu.Sh HISTORY 197a73a3ab5SRuslan ErmilovSupport for 198a73a3ab5SRuslan Ermilov.Tn POSIX 199a73a3ab5SRuslan Ermilovper-process timer first appeared in 2006f59c4c0SDavid Xu.Fx 7.0 . 201