Scheduling Policy
In Win32, the scheduling policy of a thread is related to the priority class of the thread’s process. Since the process is assigned to a priority class, all threads within a process will have the same scheduling policy. To change the scheduling policy used, you would have to change the priority class of the process. Changing the priority class will affect all threads within the process.
The Threads Module does not provide any mechanism for changing the priority class of a process; you can do this directly by using the SetPriorityClass() function in the Win32 API. You should use care when doing this; running a process in the HIGH_PRIORITY_CLASS or REALTIME_PRIORITY_CLASS may interfere with normal operation of the operating system.
The Threads Module maps the Win32 priority classes to RWSchedulingPolicy values as follows:
Table 12 – Win32: Mapping of Win32 priority classes to RWSchedulingPolicy values
Win32 Priority Class
Threads Module Scheduling Policy
IDLE_PRIORITY_CLASS
RW_THR_TIME_SLICED_DYNAMIC
NORMAL_PRIORITY_CLASS
RW_THR_TIME_SLICED_DYNAMIC
HIGH_PRIORITY_CLASS
RW_THR_TIME_SLICED_DYNAMIC
REALTIME_PRIORITY_CLASS
RW_THR_TIME_SLICED_FIXED
The default priority class for a process is NORMAL_PRIORITY_CLASS, unless the priority class of the creating process is IDLE_PRIORITY_CLASS, in which case the default priority class of the child process is IDLE_PRIORITY_CLASS.
Each Win32 priority class defines a different base priority value for threads created in that class; see Scheduling Priority for additional information.
You may query for the default scheduling policy, and may set the scheduling policy to match the current scheduling policy, but any attempt to change the policy will produce an RWTHROperationNotAvailable exception.
The default scheduling policy is determined by querying the API for the priority-class of the current process and converting that result to a scheduling policy according to the mapping defined in the previous table.