The dispatcher's task is to give control to the proper thread. The definition of 'proper' thread can be difficult to state. My approach to this problem is to state the obvious cases, and then to focus on what is left. In a sense, this discussion parallels the logic in the dispatcher.
For example, a page fault will result in temporarily blocking this priority thread.
Note: The numbers above are what the programmer specifies in DosSetPriority, or the 16-bit API DosSetPrty, and are what is returned by DosGetPriority. OS/2 processes these class numbers to create an internal dispatching priority. There are 32 priority levels in each class, which range from 00 to 1F. The priority levels, or deltas, stay the same as the programmer specified initially, if PRIORITY=ABSOLUTE is specified.
The internal priorities have a range from 01 to 08, with 01 usually used
for idle-class threads, and 08 usually used for time-critical threads. If
PRIORITY=DYNAMIC was specified or defaulted, there are priority boosts given
for the following reasons:
Being the foreground process; and for owning the keyboard;
Yielding the processor before the end of the time slice
IO completion
Being 'starved', that is, ready status and not dispatched for MAXWAIT seconds.
Dispatching is the process of finding the correct ready thread, and then giving control to it. Within each class, the priority delta is used to choose which thread should have control. When several ready threads have the same priority, control is given in turn to each of them, based on the TIMESLICE parameter. The minimum value of this parameter is the duration of the priority boosts which may be applied. The maximum value is the longest a thread can execute before being pre-empted for other threads which have the same internal dispatching priority.
As long as a group of threads at some priority use all the processor, control is not given to lower priority threads. What happens is that the other waiting threads become 'starved' after MAXWAIT seconds have elapsed, and their priority increases until they receive at least a minimum timeslice.
Idle-class threads are never starved, and so will not receive this boost.
Note:
When running in the kernel and device drivers, pre-emption can not occur. Threads must explicitly give up their time-slice to give other threads an opportunity to run.