1*bb5eebe6SDavid Xu.\" 2*bb5eebe6SDavid Xu.\" Redistribution and use in source and binary forms, with or without 3*bb5eebe6SDavid Xu.\" modification, are permitted provided that the following conditions 4*bb5eebe6SDavid Xu.\" are met: 5*bb5eebe6SDavid Xu.\" 1. Redistributions of source code must retain the above copyright 6*bb5eebe6SDavid Xu.\" notice(s), this list of conditions and the following disclaimer as 7*bb5eebe6SDavid Xu.\" the first lines of this file unmodified other than the possible 8*bb5eebe6SDavid Xu.\" addition of one or more copyright notices. 9*bb5eebe6SDavid Xu.\" 2. Redistributions in binary form must reproduce the above copyright 10*bb5eebe6SDavid Xu.\" notice(s), this list of conditions and the following disclaimer in 11*bb5eebe6SDavid Xu.\" the documentation and/or other materials provided with the 12*bb5eebe6SDavid Xu.\" distribution. 13*bb5eebe6SDavid Xu.\" 14*bb5eebe6SDavid Xu.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY 15*bb5eebe6SDavid Xu.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16*bb5eebe6SDavid Xu.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17*bb5eebe6SDavid Xu.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE 18*bb5eebe6SDavid Xu.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19*bb5eebe6SDavid Xu.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20*bb5eebe6SDavid Xu.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 21*bb5eebe6SDavid Xu.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22*bb5eebe6SDavid Xu.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 23*bb5eebe6SDavid Xu.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 24*bb5eebe6SDavid Xu.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25*bb5eebe6SDavid Xu.\" 26*bb5eebe6SDavid Xu.\" $FreeBSD$ 27*bb5eebe6SDavid Xu.\" 28*bb5eebe6SDavid Xu.Dd Sep 11, 2000 29*bb5eebe6SDavid Xu.Dt TIMER_SETTIME 2 30*bb5eebe6SDavid Xu.Os 31*bb5eebe6SDavid Xu.Sh NAME 32*bb5eebe6SDavid Xu.Nm timer_getoverrun 33*bb5eebe6SDavid Xu.Nm timer_gettime 34*bb5eebe6SDavid Xu.Nm timer_settime 35*bb5eebe6SDavid Xu.Nd per-process timers (REALTIME) 36*bb5eebe6SDavid Xu.Sh LIBRARY 37*bb5eebe6SDavid Xu.Lb libc 38*bb5eebe6SDavid Xu.Sh SYNOPSIS 39*bb5eebe6SDavid Xu.In time.h 40*bb5eebe6SDavid Xu.Ft int 41*bb5eebe6SDavid Xu.Fn timer_getoverrun "timer_t timerid" 42*bb5eebe6SDavid Xu.Ft int 43*bb5eebe6SDavid Xu.Fn timer_gettime "timer_t timerid" "struct itimerspec *value" 44*bb5eebe6SDavid Xu.Ft int 45*bb5eebe6SDavid Xu.Fn timer_settime "timer_t timerid" "int flags" "const struct itimerspec *restrict value" "struct itimerspec *restrict ovalue" 46*bb5eebe6SDavid Xu.Sh DESCRIPTION 47*bb5eebe6SDavid XuThe 48*bb5eebe6SDavid Xu.Fn timer_gettime 49*bb5eebe6SDavid Xufunction stores the amount of time until the specified timer, 50*bb5eebe6SDavid Xu.Fa timerid , 51*bb5eebe6SDavid Xuexpires and the reload value of the timer into the space pointed to by the 52*bb5eebe6SDavid Xu.Fa value 53*bb5eebe6SDavid Xuargument. The it_value member of this structure contains the amount of time 54*bb5eebe6SDavid Xubefore the timer expires, or zero if the timer is disarmed. This value is 55*bb5eebe6SDavid Xureturned as the interval until timer expiration, even if the timer was armed 56*bb5eebe6SDavid Xuwith absolute time. The it_interval member of value contains the reload 57*bb5eebe6SDavid Xuvalue last set by 58*bb5eebe6SDavid Xu.Fn timer_settime . 59*bb5eebe6SDavid Xu.Pp 60*bb5eebe6SDavid XuThe 61*bb5eebe6SDavid Xu.Fn timer_settime 62*bb5eebe6SDavid Xufunction sets the time until the next expiration of the timer specified 63*bb5eebe6SDavid Xuby 64*bb5eebe6SDavid Xu.Fa timerid 65*bb5eebe6SDavid Xufrom the it_value member of the value argument and arm the timer if the 66*bb5eebe6SDavid Xuit_value member of value is non-zero. If the specified timer was already 67*bb5eebe6SDavid Xuarmed when 68*bb5eebe6SDavid Xu.Fn timer_settime 69*bb5eebe6SDavid Xuis called, this call resets the time until next expiration to the value 70*bb5eebe6SDavid Xuspecified. If the it_value member of value is zero, the timer is disarmed. 71*bb5eebe6SDavid XuIf the timer is disarmed, then pending signal is removed. 72*bb5eebe6SDavid Xu.Pp 73*bb5eebe6SDavid XuIf the flag TIMER_ABSTIME is not set in the argument 74*bb5eebe6SDavid Xu.Fa flags , 75*bb5eebe6SDavid Xu.Fn timer_settime 76*bb5eebe6SDavid Xubehaves as if the time until next expiration is set to 77*bb5eebe6SDavid Xube equal to the interval specified by the it_value member of value. That is, 78*bb5eebe6SDavid Xuthe timer expires in it_value nanoseconds from when the call is made. If the 79*bb5eebe6SDavid Xuflag TIMER_ABSTIME is set in the argument flags, 80*bb5eebe6SDavid Xu.Fn timer_settime 81*bb5eebe6SDavid Xubehaves as if the time until next expiration is set to be equal to the 82*bb5eebe6SDavid Xudifference between the absolute time specified by the it_value member of 83*bb5eebe6SDavid Xuvalue and the current value of the clock associated with 84*bb5eebe6SDavid Xu.Fa timerid . 85*bb5eebe6SDavid XuThat is, the timer expires when the clock reaches the value specified by the 86*bb5eebe6SDavid Xuit_value member of value. If the specified time has already passed, the 87*bb5eebe6SDavid Xufunction succeeds and the expiration notification is made. 88*bb5eebe6SDavid Xu.Pp 89*bb5eebe6SDavid XuThe reload value of the timer is set to the value specified by the it_interval 90*bb5eebe6SDavid Xumember of value. When a timer is armed with a non-zero it_interval, a periodic 91*bb5eebe6SDavid Xu(or repetitive) timer is specified. 92*bb5eebe6SDavid Xu.Pp 93*bb5eebe6SDavid XuTime values that are between two consecutive non-negative integer multiples of 94*bb5eebe6SDavid Xuthe resolution of the specified timer is rounded up to the larger multiple of 95*bb5eebe6SDavid Xuthe resolution. Quantization error will not cause the timer to expire earlier 96*bb5eebe6SDavid Xuthan the rounded time value. 97*bb5eebe6SDavid Xu.Pp 98*bb5eebe6SDavid XuIf the argument ovalue is not NULL, the 99*bb5eebe6SDavid Xu.Fn timer_settime 100*bb5eebe6SDavid Xufunction stores, in the location referenced by ovalue, a value representing 101*bb5eebe6SDavid Xuthe previous amount of time before the timer would have expired, or zero if the 102*bb5eebe6SDavid Xutimer was disarmed, together with the previous timer reload value. Timers is not 103*bb5eebe6SDavid Xuexpire before their scheduled time. 104*bb5eebe6SDavid Xu.Pp 105*bb5eebe6SDavid XuOnly a single signal is queued to the process for a given timer at any point in 106*bb5eebe6SDavid Xutime. When a timer for which a signal is still pending expires, no signal is 107*bb5eebe6SDavid Xuqueued, and a timer overrun will occur. When a timer expiration signal is 108*bb5eebe6SDavid Xuaccepted by a process, the 109*bb5eebe6SDavid Xu.Fn timer_getoverrun 110*bb5eebe6SDavid Xufunction returns the timer expiration overrun count for the specified timer. 111*bb5eebe6SDavid XuThe overrun count returned contains the number of extra timer expirations that 112*bb5eebe6SDavid Xuoccurred between the time the signal was generated (queued) and when it was 113*bb5eebe6SDavid Xuaccepted, up to but not including an maximum of {DELAYTIMER_MAX}. If the number of 114*bb5eebe6SDavid Xusuch extra expirations is greater than or equal to {DELAYTIMER_MAX}, then the 115*bb5eebe6SDavid Xuoverrun count is set to {DELAYTIMER_MAX}. The value returned by 116*bb5eebe6SDavid Xu.Fn timer_getoverrun 117*bb5eebe6SDavid Xuapplies to the most recent expiration signal acceptance for the timer. If no 118*bb5eebe6SDavid Xuexpiration signal has been delivered for the timer, the return value of 119*bb5eebe6SDavid Xu.Fn timer_getoverrun 120*bb5eebe6SDavid Xuis unspecified. 121*bb5eebe6SDavid Xu.Sh RETURN VALUES 122*bb5eebe6SDavid XuIf the 123*bb5eebe6SDavid Xu.Fn timer_getoverrun 124*bb5eebe6SDavid Xufunction succeeds, it returns the timer expiration overrun count as explained 125*bb5eebe6SDavid Xuabove. 126*bb5eebe6SDavid Xu.Pp 127*bb5eebe6SDavid XuIf the 128*bb5eebe6SDavid Xu.Fn timer_gettime 129*bb5eebe6SDavid Xuor 130*bb5eebe6SDavid Xu.Fn timer_settime 131*bb5eebe6SDavid Xufunctions succeed, a value of 0 is returned. 132*bb5eebe6SDavid Xu.Pp 133*bb5eebe6SDavid XuIf an error occurs for any of these functions, the value -1 is returned, and 134*bb5eebe6SDavid Xuerrno set to indicate the error. 135*bb5eebe6SDavid Xu.Sh ERRORS 136*bb5eebe6SDavid XuThe 137*bb5eebe6SDavid Xu.Fn timer_settime 138*bb5eebe6SDavid Xuwill fail if: 139*bb5eebe6SDavid Xu.Bl -tag -width Er 140*bb5eebe6SDavid Xu.It Bq Er EINVAL 141*bb5eebe6SDavid XuA value structure specified a nanosecond value less than zero or greater than 142*bb5eebe6SDavid Xuor equal to 1000 million, and the it_value member of that structure did not 143*bb5eebe6SDavid Xuspecify zero seconds and nanoseconds. 144*bb5eebe6SDavid Xu.El 145*bb5eebe6SDavid Xu.Pp 146*bb5eebe6SDavid XuThese functions may fail if: 147*bb5eebe6SDavid Xu.Bl -tag -width Er 148*bb5eebe6SDavid Xu.It Bq Er EINVAL 149*bb5eebe6SDavid XuThe 150*bb5eebe6SDavid Xu.Fa timerid 151*bb5eebe6SDavid Xuargument does not correspond to an ID returned by 152*bb5eebe6SDavid Xu.Fn timer_create 153*bb5eebe6SDavid Xubut not yet deleted by 154*bb5eebe6SDavid Xu.Fn timer_delete . 155*bb5eebe6SDavid Xu.El 156*bb5eebe6SDavid Xu.Pp 157*bb5eebe6SDavid XuThe timer_settime() function may fail if: 158*bb5eebe6SDavid Xu.Bl -tag -width Er 159*bb5eebe6SDavid Xu.It Bq Er EINVAL 160*bb5eebe6SDavid XuThe it_interval member of value is not zero and the timer was created with 161*bb5eebe6SDavid Xunotification by creation of a new thread ( sigev_sigev_notify was SIGEV_THREAD) 162*bb5eebe6SDavid Xuand a fixed stack address has been set in the thread attribute pointed to by 163*bb5eebe6SDavid Xusigev_notify_attributes. 164*bb5eebe6SDavid Xu.El 165*bb5eebe6SDavid Xu.Pp 166*bb5eebe6SDavid XuThe 167*bb5eebe6SDavid Xu.Fn timer_gettime 168*bb5eebe6SDavid Xuand 169*bb5eebe6SDavid Xu.Fn timer_settime 170*bb5eebe6SDavid Xumay fail if: 171*bb5eebe6SDavid Xu.Bl -tag -width Er 172*bb5eebe6SDavid Xu.It Bq Er EFAULT 173*bb5eebe6SDavid XuAny arguments point outside the allocated address space or there is a 174*bb5eebe6SDavid Xumemory protection fault. 175*bb5eebe6SDavid Xu.El 176*bb5eebe6SDavid Xu.Sh SEE ALSO 177*bb5eebe6SDavid Xu.Xr clock_getres 2 , 178*bb5eebe6SDavid Xu.Xr timer_create 2 179*bb5eebe6SDavid Xu.Sh STANDARDS 180*bb5eebe6SDavid XuThe 181*bb5eebe6SDavid Xu.Fn timer_getoverrun , 182*bb5eebe6SDavid Xu.Fn timer_gettime , 183*bb5eebe6SDavid Xuand 184*bb5eebe6SDavid Xu.Fn timer_settime 185*bb5eebe6SDavid Xufunction conform to 186*bb5eebe6SDavid Xu.St -p1003.1-96 . 187