RtCreateTimer

RtCreateTimer creates a timer associated with the specified clock, and returns a handle to the timer.

Syntax

HANDLE RtCreateTimer(
    PSECURITY_ATTRIBUTES pThreadAttributes,
    ULONG StackSize,
    VOID (RTFCNDCL *Routine) (PVOID context),
    PVOID Context,
    ULONG Priority,
    CLOCK Clock
);

Parameters

pThreadAttributes (ignored by RTSS)

An optional pointer to a SECURITY_ATTRIBUTES structure to be used at handler thread creation. Pass in NULL for default.

StackSize

The stack size for handler thread. Use a size of 0 for default.

Routine

A pointer to the routine to be run upon completion. The routine takes a single PVOID argument and returns VOID.

Context

The argument to the routine, cast as a PVOID.

Priority

The handler thread priority as defined below.

Clock

A clock identifier as defined below in the Comments sections.

Return Values

A non-zero handle to the timer if the function succeeds, A NULL handle if the function fails

To set the timer to expire, see RtSetTimer or RtSetTimerRelative. When the timer expires, the specified routine runs with the specified argument.

Remarks

RtCreateTimer allocates a new timer and returns a handle to it. Legal clock values, as enumerated in rtapi.h, are listed below:

Clock Value

Meaning

CLOCK_1

One millisecond timer.

CLOCK_2

Real-time HAL timer. Default is 100 microseconds.

CLOCK_3

Real-time HAL timer.  Use the actual timer period to set and deliver the clock values, to calculate the expiration values and response latencies of timers based on this clock.

CLOCK_FASTEST

The fastest available clock and time on the system. This is usually CLOCK_2.

CLOCK_SYSTEM

Same as CLOCK_1.

The timer routine will run as a separate handling thread. pThreadAttributes, StackSize, and Priority are used to control the creation of the handler thread. See CreateThread and SetThreadPriority for details on these parameters.

To run a different handling routine/context, a new timer must be created.

NOTE:  If you call RtCreateTimer on a system with more than one processor, the processor affinity for the timer handler will default to the affinity of the calling process or thread. For information about setting processor affinity, see RtCreateTimerEx.

Requirements

Header Rtapi.h
Library rtapi_w32.lib (Windows), Rtx_Rtss.lib (RTSS)

See Also:

RtCancelTimer

RtDeleteTimer

RtGetClockResolution

RtGetClockTime

RtGetClockTimerPeriod

RtSetClockTime

RtSetTimer

RtSetTimerRelative

IntervalZero.com | Support | Give Feedback