[Previous] [Contents] [Index] [Next]

Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

TimerCreate(), TimerCreate_r()

Create a timer for a process

Synopsis:

#include <sys/neutrino.h>

int TimerCreate( clockid_t id,
                 const struct sigevent *event );

int TimerCreate_r( clockid_t id,
                   const struct sigevent *event );

Arguments:

id
The timing base; supported types are:
event
NULL, or a pointer to a sigevent structure that contains the event to deliver when the timer fires; see below.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The TimerCreate() and TimerCreate_r() kernel calls create a per-process timer using the clock specified by id as the timing base.

These functions are identical except in the way they indicate errors. See the Returns section for details.


Note: Instead of using these kernel calls directly, consider calling timer_create().

Use the returned timer ID in subsequent calls to the other timer functions.

The timer is created in the disabled state, and isn't enabled until you call TimerSettime().

The sigevent structure pointed to by event contains the event to deliver when the timer fires. We recommend the following event types in this case:

If the event argument is NULL, a SIGALRM signal is sent to your process when the timer expires. To specify a handler for this signal, call sigaction().

Blocking states

These calls don't block.

Returns:

The only difference between these functions is the way they indicate errors:

TimerCreate()
The timer ID of the newly created timer. If an error occurs, -1 is returned and errno is set.
TimerCreate_r()
The timer ID of the newly created timer. This function does NOT set errno. If an error occurs, the negative of a value from the Errors section is returned.

Errors:

EINVAL
The clock ID isn't valid.
EAGAIN
All kernel timer objects are in use.
EFAULT
A fault occurred when the kernel tried to access the buffers provided.

Classification:

QNX Neutrino

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

sigevent, timer_create(), TimerAlarm(), TimerDestroy(), TimerInfo(), TimerSettime(), TimerTimeout()


[Previous] [Contents] [Index] [Next]