Priority Classes

OS/2 uses four priority classes to determine when a thread receives a time slice:

Priority Classes

┌──────────────────────────────┬──────────────────────────────┐
│Priority                      │Description                   │
├──────────────────────────────┼──────────────────────────────┤
│Time-critical                 │Highest priority.  For use    │
│                              │when response time is         │
│                              │critical.                     │
├──────────────────────────────┼──────────────────────────────┤
│Fixed-high                    │Used by threads that provide  │
│                              │service to other threads. This│
│                              │priority class is to be used  │
│                              │when it is desirable that the │
│                              │thread not be too sensitive to│
│                              │the foreground/background     │
│                              │boost provided by dynamic     │
│                              │priority variation. It is     │
│                              │meant for programs that need  │
│                              │to execute before regular     │
│                              │programs, but without the     │
│                              │immediate response time       │
│                              │requirement called for by     │
│                              │time-critical threads.        │
├──────────────────────────────┼──────────────────────────────┤
│Regular                       │Default priority.  Most       │
│                              │threads belong in this class. │
├──────────────────────────────┼──────────────────────────────┤
│Idle-time                     │Lowest priority.  This        │
│                              │priority only gets CPU time   │
│                              │when there is no other work to│
│                              │do.                           │
└──────────────────────────────┴──────────────────────────────┘

A time-critical thread always receives a time slice before a fixed-high thread, a fixed-high thread always receives a time slice before a regular thread, and a regular thread always receives a time slice before an idle-time thread.

Time-Critical Threads
Time-critical threads have the highest priority class and execute before any fixed-high, regular, or idle-time threads.

The time-critical class is for threads that must react to events outside the system. For example, in a communications application, a thread responsible for reading data from the communications device needs enough time to read all incoming data. Because more than a regular time slice might be needed, a time-critical classification ensures that the thread gets all the time required.

Time-critical threads have a static priority that is not varied by OS/2. They are scheduled among themselves in priority level order, with round-robin scheduling of threads of equal priority.

Time-critical threads must be executed quickly, then free the CPU for other work until another time-critical event occurs. This is important to maintain good interactive responsiveness to the user and enable communications and other time critical applications to run concurrently. The time-critical activity should, when possible, be in a thread separate from the rest of the application, to isolate and minimize the time spent processing at the time-critical level. A good rule of thumb is that a time-critical thread should consist of no more than about 20,000 assembly language instructions.

Fixed-High Threads
A fixed-high thread has a priority class that is lower than time-critical but executes before any regular or idle-time threads. This class of threads should be used to provide service for other threads where it is desirable that the thread not be too sensitive to the foreground/background boost provided by dynamic priority variation. A messaging thread, would be a good example of this type of thread.

OS/2 varies the priority of a fixed-high thread around a base value according to the activity of the thread and the system at any point in time. The base value can be set by the thread itself.

Regular Threads
A regular thread is the class that the majority of threads fall into. No explicit action is necessary by the application to run at this priority, it is the default.

OS/2 varies the priority level of a regular thread around a base value according to the activity of the thread and the system at any point in time. The base value can be set by the thread itself.

Idle-Time Threads
An idle-time thread is one with very low priority that executes only when there are no regular, fixed-high, or time-critical threads to execute. Idle-time threads get CPU time only when there is no other work to do. The idle-time class is for threads that need very little CPU time.

Idle-time threads have a static priority that is not varied by OS/2.


[Back: About CPU Scheduling]
[Next: Priority Levels]