2005-11-18 12:53:23 +01:00
|
|
|
.\" Copyright (c) 2005 David Xu <davidxu@FreeBSD.org>
|
2005-11-12 02:19:05 +01:00
|
|
|
.\" All rights reserved.
|
2005-11-11 08:48:38 +01:00
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice(s), this list of conditions and the following disclaimer as
|
|
|
|
.\" the first lines of this file unmodified other than the possible
|
|
|
|
.\" addition of one or more copyright notices.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice(s), this list of conditions and the following disclaimer in
|
|
|
|
.\" the documentation and/or other materials provided with the
|
|
|
|
.\" distribution.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
|
|
|
|
.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
|
|
|
|
.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
|
|
.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
|
|
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
|
|
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
2009-01-12 14:12:02 +01:00
|
|
|
.Dd January 12, 2009
|
2005-11-11 08:48:38 +01:00
|
|
|
.Dt TIMER_CREATE 2
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm timer_create
|
2005-11-18 12:53:23 +01:00
|
|
|
.Nd "create a per-process timer (REALTIME)"
|
2005-11-11 08:48:38 +01:00
|
|
|
.Sh LIBRARY
|
2007-06-18 03:50:03 +02:00
|
|
|
.Lb librt
|
2005-11-11 08:48:38 +01:00
|
|
|
.Sh SYNOPSIS
|
|
|
|
.In time.h
|
2009-01-12 14:12:02 +01:00
|
|
|
.In signal.h
|
2005-11-11 08:48:38 +01:00
|
|
|
.Ft int
|
2005-11-18 12:53:23 +01:00
|
|
|
.Fo timer_create
|
|
|
|
.Fa "clockid_t clockid" "struct sigevent *restrict evp"
|
|
|
|
.Fa "timer_t *restrict timerid"
|
|
|
|
.Fc
|
2005-11-11 08:48:38 +01:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Fn timer_create
|
2005-11-18 12:53:23 +01:00
|
|
|
system call creates a per-process timer using the specified clock,
|
2005-11-11 08:48:38 +01:00
|
|
|
.Fa clock_id ,
|
2005-11-18 12:53:23 +01:00
|
|
|
as the timing base.
|
|
|
|
The
|
2005-11-11 08:48:38 +01:00
|
|
|
.Fn timer_create
|
2005-11-18 12:53:23 +01:00
|
|
|
system call returns, in the location referenced by
|
2005-11-11 08:48:38 +01:00
|
|
|
.Fa timerid ,
|
2005-11-18 12:53:23 +01:00
|
|
|
a timer ID of type
|
|
|
|
.Vt timer_t
|
|
|
|
used to identify the timer in timer requests.
|
2005-11-11 08:48:38 +01:00
|
|
|
This timer ID is unique within the calling process until the timer is deleted.
|
|
|
|
The particular clock,
|
|
|
|
.Fa clock_id ,
|
|
|
|
is defined in
|
|
|
|
.In time.h .
|
|
|
|
The timer whose ID is returned is in a disarmed state upon return from
|
|
|
|
.Fn timer_create .
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fa evp
|
2005-11-18 12:53:23 +01:00
|
|
|
argument, if
|
|
|
|
.Pf non- Dv NULL ,
|
|
|
|
points to a
|
|
|
|
.Vt sigevent
|
|
|
|
structure.
|
|
|
|
This structure,
|
2005-11-11 08:48:38 +01:00
|
|
|
allocated by the application, defines the asynchronous notification to occur
|
2005-11-18 12:53:23 +01:00
|
|
|
when the timer expires.
|
|
|
|
If the
|
|
|
|
.Fa evp
|
|
|
|
argument is
|
|
|
|
.Dv NULL ,
|
|
|
|
the effect is as if the
|
2005-11-11 08:48:38 +01:00
|
|
|
.Fa evp
|
2005-11-18 12:53:23 +01:00
|
|
|
argument pointed to a
|
|
|
|
.Vt sigevent
|
|
|
|
structure with the
|
|
|
|
.Va sigev_notify
|
|
|
|
member having the value
|
|
|
|
.Dv SIGEV_SIGNAL ,
|
|
|
|
the
|
|
|
|
.Va sigev_signo
|
|
|
|
having a default signal number, and the
|
|
|
|
.Va sigev_value
|
|
|
|
member having
|
2005-11-11 08:48:38 +01:00
|
|
|
the value of the timer ID.
|
|
|
|
.Pp
|
2005-11-18 12:53:23 +01:00
|
|
|
The implementations supports a
|
|
|
|
.Fa clock_id
|
|
|
|
of
|
|
|
|
.Dv CLOCK_REALTIME
|
|
|
|
or
|
|
|
|
.Dv CLOCK_MONOTONIC .
|
2005-11-11 08:48:38 +01:00
|
|
|
.Pp
|
2005-11-18 12:53:23 +01:00
|
|
|
If
|
2009-01-12 14:12:02 +01:00
|
|
|
.Fa evp->sigev_notify
|
2005-11-18 12:53:23 +01:00
|
|
|
is
|
|
|
|
.Dv SIGEV_THREAD
|
|
|
|
and
|
|
|
|
.Fa sev->sigev_notify_attributes
|
|
|
|
is not
|
|
|
|
.Dv NULL ,
|
|
|
|
if the attribute pointed to by
|
|
|
|
.Fa sev->sigev_notify_attributes
|
|
|
|
has
|
2005-11-11 08:48:38 +01:00
|
|
|
a thread stack address specified by a call to
|
|
|
|
.Fn pthread_attr_setstack
|
|
|
|
or
|
|
|
|
.Fn pthread_attr_setstackaddr ,
|
|
|
|
the results are unspecified if the signal is generated more than once.
|
|
|
|
.Sh RETURN VALUES
|
|
|
|
If the call succeeds,
|
|
|
|
.Fn timer_create
|
2005-11-18 12:53:23 +01:00
|
|
|
returns zero and updates the location referenced by
|
|
|
|
.Fa timerid
|
|
|
|
to a
|
|
|
|
.Vt timer_t ,
|
|
|
|
which can be passed to the per-process timer calls.
|
|
|
|
If an error
|
|
|
|
occurs, the system call returns a value of \-1
|
|
|
|
and the global variable
|
|
|
|
.Va errno
|
|
|
|
is set to indicate the
|
|
|
|
error.
|
|
|
|
The value of
|
2005-11-11 08:48:38 +01:00
|
|
|
.Fa timerid
|
2005-11-18 12:53:23 +01:00
|
|
|
is undefined if an error occurs.
|
2005-11-11 08:48:38 +01:00
|
|
|
.Sh ERRORS
|
|
|
|
The
|
|
|
|
.Fn timer_create
|
2005-11-18 12:53:23 +01:00
|
|
|
system call
|
2005-11-11 08:48:38 +01:00
|
|
|
will fail if:
|
|
|
|
.Bl -tag -width Er
|
|
|
|
.It Bq Er EAGAIN
|
|
|
|
The calling process has already created all of the timers it is allowed by
|
2005-11-18 12:53:23 +01:00
|
|
|
this implementation.
|
2005-11-11 08:48:38 +01:00
|
|
|
.It Bq Er EINVAL
|
|
|
|
The specified clock ID is not supported.
|
|
|
|
.It Bq Er EFAULT
|
|
|
|
Any arguments point outside the allocated address space or there is a
|
|
|
|
memory protection fault.
|
|
|
|
.El
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr clock_getres 2 ,
|
|
|
|
.Xr timer_delete 2 ,
|
2005-12-13 14:43:35 +01:00
|
|
|
.Xr timer_getoverun 2 ,
|
|
|
|
.Xr siginfo 3
|
2005-11-11 08:48:38 +01:00
|
|
|
.Sh STANDARDS
|
|
|
|
The
|
|
|
|
.Fn timer_create
|
2005-11-18 12:53:23 +01:00
|
|
|
system call conforms to
|
2005-11-30 05:15:44 +01:00
|
|
|
.St -p1003.1-2004
|
|
|
|
.Sh HISTORY
|
2006-09-17 23:27:35 +02:00
|
|
|
Support for
|
|
|
|
.Tn POSIX
|
|
|
|
per-process timer first appeared in
|
2005-11-30 05:15:44 +01:00
|
|
|
.Fx 7.0 .
|