xref: /minix3/lib/libc/sys/timer_settime.2 (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
1*84d9c625SLionel Sambuc.\"	$NetBSD: timer_settime.2,v 1.9 2012/11/06 23:25:44 wiz Exp $
22fe8fb19SBen Gras.\"
32fe8fb19SBen Gras.\" Copyright (c) 2003 The NetBSD Foundation, Inc.
42fe8fb19SBen Gras.\" All rights reserved.
52fe8fb19SBen Gras.\"
62fe8fb19SBen Gras.\" This code is derived from software contributed to The NetBSD Foundation
72fe8fb19SBen Gras.\" by Christos Zoulas.
82fe8fb19SBen Gras.\"
92fe8fb19SBen Gras.\" Redistribution and use in source and binary forms, with or without
102fe8fb19SBen Gras.\" modification, are permitted provided that the following conditions
112fe8fb19SBen Gras.\" are met:
122fe8fb19SBen Gras.\" 1. Redistributions of source code must retain the above copyright
132fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer.
142fe8fb19SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright
152fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer in the
162fe8fb19SBen Gras.\"    documentation and/or other materials provided with the distribution.
172fe8fb19SBen Gras.\"
182fe8fb19SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
192fe8fb19SBen Gras.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
202fe8fb19SBen Gras.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
212fe8fb19SBen Gras.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
222fe8fb19SBen Gras.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
232fe8fb19SBen Gras.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
242fe8fb19SBen Gras.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
252fe8fb19SBen Gras.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
262fe8fb19SBen Gras.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
272fe8fb19SBen Gras.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
282fe8fb19SBen Gras.\" POSSIBILITY OF SUCH DAMAGE.
292fe8fb19SBen Gras.\"
302fe8fb19SBen Gras.Dd May 17, 2010
312fe8fb19SBen Gras.Dt TIMER_SETTIME 2
322fe8fb19SBen Gras.Os
332fe8fb19SBen Gras.Sh NAME
342fe8fb19SBen Gras.Nm timer_settime ,
352fe8fb19SBen Gras.Nm timer_gettime ,
362fe8fb19SBen Gras.Nm timer_getoverrun
372fe8fb19SBen Gras.Nd process timer manipulation
382fe8fb19SBen Gras.Sh LIBRARY
392fe8fb19SBen Gras.Lb libc
402fe8fb19SBen Gras.Sh SYNOPSIS
412fe8fb19SBen Gras.In time.h
422fe8fb19SBen Gras.Ft int
432fe8fb19SBen Gras.Fn timer_settime "timer_t timerid" "int flags" "const struct itimerspec * restrict tim" "struct itimerspec * restrict otim"
442fe8fb19SBen Gras.Ft int
452fe8fb19SBen Gras.Fn timer_gettime "timer_t timerid" "struct itimerspec *tim"
462fe8fb19SBen Gras.Ft int
472fe8fb19SBen Gras.Fn timer_getoverrun "timer_t timerid"
482fe8fb19SBen Gras.Sh DESCRIPTION
492fe8fb19SBen GrasThe
502fe8fb19SBen Gras.Fn timer_settime
512fe8fb19SBen Grassets the next expiration time of the timer with ID
522fe8fb19SBen Gras.Ar timerid
532fe8fb19SBen Grasto the
542fe8fb19SBen Gras.Fa it_value
552fe8fb19SBen Gras(see
562fe8fb19SBen Gras.Xr itimerspec 3 )
572fe8fb19SBen Grasspecified in the
582fe8fb19SBen Gras.Ar tim
592fe8fb19SBen Grasargument.
602fe8fb19SBen GrasIf the value is 0, the timer is disarmed.
612fe8fb19SBen GrasIf the argument
622fe8fb19SBen Gras.Ar otim
632fe8fb19SBen Grasis not
642fe8fb19SBen Gras.Dv NULL
65*84d9c625SLionel Sambucthe old timer settings are returned.
662fe8fb19SBen Gras.Pp
672fe8fb19SBen GrasIf the
682fe8fb19SBen Gras.Ar flags
692fe8fb19SBen Grasargument is set to
702fe8fb19SBen Gras.Dv TIMER_RELTIME
712fe8fb19SBen Grasthen the expiration time is set to the value in nanoseconds specified
722fe8fb19SBen Grasin the
732fe8fb19SBen Gras.Ar tim
742fe8fb19SBen Grasargument from the time the call to
752fe8fb19SBen Gras.Fn timer_settime
762fe8fb19SBen Graswas made.
772fe8fb19SBen GrasIf the
782fe8fb19SBen Gras.Ar flags
792fe8fb19SBen Grasargument is set to
802fe8fb19SBen Gras.Dv TIMER_ABSTIME
812fe8fb19SBen Grasthen the expiration time is set to be equal to the difference between the
822fe8fb19SBen Grasclock associated with this timer, and the value specified in the
832fe8fb19SBen Gras.Ar tim
842fe8fb19SBen Grasargument.
852fe8fb19SBen GrasIf that time has already passed, then the call succeeds, and the
862fe8fb19SBen Grasexpiration notification occurs.
872fe8fb19SBen Gras.Pp
882fe8fb19SBen GrasIf the
892fe8fb19SBen Gras.Fa it_interval
902fe8fb19SBen Grasof the
912fe8fb19SBen Gras.Ar tim
922fe8fb19SBen Grasargument is non-zero, then the timer reloads upon expiration.
932fe8fb19SBen Gras.Pp
942fe8fb19SBen GrasThe
952fe8fb19SBen Gras.Fn timer_gettime
962fe8fb19SBen Grasfunction returns the current settings of the timer
972fe8fb19SBen Grasspecified by the
982fe8fb19SBen Gras.Ar timerid
992fe8fb19SBen Grasargument in the
1002fe8fb19SBen Gras.Ar tim
1012fe8fb19SBen Grasargument.
1022fe8fb19SBen Gras.Pp
1032fe8fb19SBen GrasOnly one notification event (signal) can be pending for a given timer
1042fe8fb19SBen Grasand process.
1052fe8fb19SBen GrasIf a timer expires while the signal is still queued for delivery, then
1062fe8fb19SBen Grasthe overrun counter for that timer is increased.
1072fe8fb19SBen GrasThe counter can store values up to
1082fe8fb19SBen Gras.Dv DELAYTIMER_MAX .
1092fe8fb19SBen GrasWhen the signal is finally delivered to the process, then the
1102fe8fb19SBen Gras.Fn timer_getoverrun
1112fe8fb19SBen Grasfunction can be used to retrieve the overrun counter for the timer
1122fe8fb19SBen Grasspecified in the
1132fe8fb19SBen Gras.Ar timerid
1142fe8fb19SBen Grasargument.
1152fe8fb19SBen Gras.Sh NOTES
1162fe8fb19SBen GrasExpiration time values are always rounded up to the resolution of the timer,
1172fe8fb19SBen Grasso a notification will never be sent before the requested time.
1182fe8fb19SBen GrasValues returned in the
1192fe8fb19SBen Gras.Ar otim
1202fe8fb19SBen Grasargument of
1212fe8fb19SBen Gras.Fn timer_settime
1222fe8fb19SBen Grasor in the
1232fe8fb19SBen Gras.Ar tim
124*84d9c625SLionel Sambucargument of
1252fe8fb19SBen Gras.Fn timer_gettime
1262fe8fb19SBen Grasare subject to the above rounding effect and might not exactly match the
1272fe8fb19SBen Grasrequested values by the user.
1282fe8fb19SBen Gras.Sh RETURN VALUES
1292fe8fb19SBen GrasIf successful, the
1302fe8fb19SBen Gras.Fn timer_gettime
1312fe8fb19SBen Grasand
1322fe8fb19SBen Gras.Fn timer_settime
1332fe8fb19SBen Grasfunctions return 0, and the
1342fe8fb19SBen Gras.Fn timer_getoverrun
1352fe8fb19SBen Grasfunction returns the expiration overrun count for the specified timer.
1362fe8fb19SBen GrasOtherwise, the functions return \-1, and set
1372fe8fb19SBen Gras.Dv errno
1382fe8fb19SBen Grasto indicate the error.
1392fe8fb19SBen Gras.Sh ERRORS
1402fe8fb19SBen GrasThe
1412fe8fb19SBen Gras.Fn timer_gettime ,
1422fe8fb19SBen Gras.Fn timer_getoverrun ,
1432fe8fb19SBen Grasand
1442fe8fb19SBen Gras.Fn timer_settime
1452fe8fb19SBen Grasfunctions will fail if:
1462fe8fb19SBen Gras.Bl -tag -width Er
1472fe8fb19SBen Gras.It Bq Er EINVAL
1482fe8fb19SBen GrasThe argument
1492fe8fb19SBen Gras.Ar timerid
1502fe8fb19SBen Grasdoes not correspond to a valid timer id as returned by
1512fe8fb19SBen Gras.Fn timer_create
1522fe8fb19SBen Grasor that timer id has been deleted by
1532fe8fb19SBen Gras.Fn timer_delete .
1542fe8fb19SBen Gras.El
1552fe8fb19SBen Gras.Pp
1562fe8fb19SBen GrasThe
1572fe8fb19SBen Gras.Fn timer_settime
1582fe8fb19SBen Grasfunction will fail if:
1592fe8fb19SBen Gras.Bl -tag -width Er
1602fe8fb19SBen Gras.It Bq Er EINVAL
1612fe8fb19SBen GrasA nanosecond field in the
1622fe8fb19SBen Gras.Ar tim
1632fe8fb19SBen Grasstructure specified a value less than zero or greater than or equal to 10e9.
1642fe8fb19SBen Gras.El
1652fe8fb19SBen Gras.Sh SEE ALSO
1662fe8fb19SBen Gras.Xr clock_gettime 2 ,
1672fe8fb19SBen Gras.Xr timer_create 2 ,
1682fe8fb19SBen Gras.Xr timer_delete 2
1692fe8fb19SBen Gras.Sh STANDARDS
1702fe8fb19SBen Gras.St -p1003.1b-93 ,
1712fe8fb19SBen Gras.St -p1003.1i-95
172*84d9c625SLionel Sambuc.\"  LocalWords:  gettime settime
173