Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/t/timercreate.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/t/timercreate.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/t/timercreate.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/t/timercreate.html on line 8
Create a timer for a process
#include <sys/neutrino.h>
int TimerCreate( clockid_t id,
const struct sigevent *event );
int TimerCreate_r( clockid_t id,
const struct sigevent *event );
- 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.
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
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.
|
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 your process executes in a loop using MsgReceivev(),
then SIGEV_PULSE is a convenient way of receiving timer
pulses.
- If you use signals for event notification, note that signals are
always delivered to the process and not directly to the thread that
created or armed the timer.
You can change this by using a
sigev_notify of SIGEV_SIGNAL_THREAD.
- The notify types of SIGEV_UNBLOCK and
SIGEV_INTR, while allowed, are of questionable use with
timers. SIGEV_UNBLOCK is typically used by the
TimerTimeout() kernel call, and SIGEV_INTR
is typically used with
the InterruptWait() kernel call.
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().
These calls don't block.
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.
- 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.
QNX Neutrino
Safety: | |
Cancellation point |
No |
Interrupt handler |
No |
Signal handler |
Yes |
Thread |
Yes |
sigevent,
timer_create(),
TimerAlarm(),
TimerDestroy(),
TimerInfo(),
TimerSettime(),
TimerTimeout()
Clocks, Timers, and Getting a Kick Every So Often
chapter of Getting Started with QNX Neutrino
Tick, Tock: Understanding the Neutrino Microkernel's Concept of Time
chapter of the QNX Neutrino Programmer's Guide
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/t/timercreate.html on line 266
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/t/timercreate.html on line 266