Processor Affinity Functions
wRTOS provides several functions for managing processor affinity for a specific thread or process.
- GetProcessAffinityMask retrieves the specified process's process affinity mask and the Real-Time Subsystem's system affinity mask.
- SetProcessAffinityMask sets a processor affinity mask for a 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. A thread must be suspended before you can set its ideal processor.
- RtCreateTimerEx creates a timer associated with the specified clock and returns a handle to it. Use this call instead of RtCreateTimer if you 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.
The functions above that set and retrieve processor affinity masks (GetProcessAffinityMask, SetProcessAffinityMask, SetThreadAffinityMask, and RtCreateTimerEx use bitmasks to represent the mask.