Open topic with navigation
Processor Affinity Functions
RTX provides a number of functions for managing processor affinity for
a specific thread or process.
- GetProcessAffinityMask
retrieves the process affinity mask for the specified process and the
system affinity mask for the Real-Time Subsystem.
- SetProcessAffinityMask
sets a processor affinity mask for specified process.
- SetThreadAffinityMask
sets a processor affinity mask for the specified thread. A thread affinity
mask must be a subset of the process affinity mask for the containing
process of a thread. A thread can only run on the processors its process
can run on. If you do not specify a processor affinity mask for a thread,
the thread will inherit the processor affinity mask from its process.
Finally, a thread must be suspended
before you can set its affinity.
- SetThreadIdealProcessor
sets a preferred processor for a thread. The RTSS subsystem always schedules
threads on their preferred processor. If you do not
specify a preferred processor for a thread, it will run on the lowest-numbered
processor in its affinity mask.
- RtCreateTimerEx
creates a timer associated with the specified clock, and returns a handle
to the timer. Use this call, instead of RtCreateTimer, if you are
developing for an RTX
dedicated system and want to set the processor affinity for the timer
handler. If you use RtCreateTimer,
the timer handler affinity will default to the affinity of the calling
thread.
- RtGetProcessAffinityMask
allows a Win32 application to get the processor affinity mask for an RTSS
process, and also to retrieve the system affinity mask for the Real-Time
Subsystem.
- RtSetProcessAffinityMask
allows a Win32 application to set the processor affinity mask for an RTSS
process.
The functions above that set and retrieve processor affinity masks (GetProcessAffinityMask, SetProcessAffinityMask,
SetThreadAffinityMask, RtGetProcessAffinityMask,
and RtSetProcessAffinityMask)
use bitmasks to represent the mask. See Specifying
a Processor Affinity Bitmask for details.
NOTE: See the Affinity Masks section of Using the Real-Time API for information on when to use RtGetProcessAffinityMask versus GetProcessAffinityMask.