RtCreateTimerEx

RtCreateTimerEx creates a timer associated with the specified clock, and returns a handle to the timer. Use this call instead of RtCreateTimer if you want to set the affinity for the timer handler.

Syntax

HANDLE RtCreateTimerEx(
    PSECURITY_ATTRIBUTES pThreadAttributes,
    ULONG StackSize,
    VOID (RTFCNDCL *pRoutine) (PVOID context),
    PVOID Context,
    ULONG Priority,
    CLOCK Clock,
    KAFFINITY ProcessorEnableMask
);

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. Legal clock values 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.

ProcessorEnableMask

Specifies the KAFFINITY mask that represents the set of RTSS processors on which the timer handler can run. See Specifying a Processor Affinity Bitmask for more details. Once a timer handler thread has started, it cannot be moved to another processor.

Return Value

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

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

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

NOTE: When called in a Windows application, RtCreateTimerEx sets the Win32 timer thread priority to THREAD_PRIORITY_TIME_CRITICAL by default, and sets the proxy thread priority based on the function parameter, Priority. You can change the priority of the Win32 timer thread priority within the first call of the timer handling routine.

NOTE: If your timer period is close to Real-time subsystem’s HAL timer period, the overhead of Subsystem tick processing may cause a much larger response latency of your timer handling routine (IST). In this case, you should configure a much smaller HAL timer period. For example, if your timer period is 100 us, you should configure HAL period to a smaller value, such as 20 us, depending on your processor frequency. See the Control Panel for how to modify the Hal timer period.

Requirements

Minimum Supported Version RTX64 2013
Header Rtapi.h
Library RtApi.lib (Windows), Rtx_Rtss.lib (RTSS)

See Also:

RtCancelTimer

RtDeleteTimer

RtGetClockResolution

RtGetClockTime

RtGetClockTimerPeriod

RtSetClockTime

RtSetTimer

RtSetTimerRelative