OSF DCE Application Development Guide--Core Components

Thread Concepts and Operations
TABLE 7-1. Sample Thread Proprities
____________________
Thread Priority
____________________
____________________
A Minimum
B Middle
C Middle
DMaximum
____________________
Figures 7-6 through 7-8 show execution flows, depending on whether the threads use the
SCHED_FIFO, SCHED_RR,or SCHED_OTHER (default) scheduling policy.
Assume that all waiting threads are ready to execute when the current thread waits or
terminates and that no higher-priority thread is awakened while a thread is executing
(during the flow shown in each figure).
Figure 7-6 shows a flow with SCHED_FIFO (First In, First Out) scheduling.
Figure 7-6. Flow with SCHED_FIFO Scheduling
DBCA
Thread D executes until it waits or terminates, then Thread B starts because it has been
waiting longer than Thread C and it executes until it waits or terminates, then Thread C
executes until it waits or terminates, then Thread A executes.
Figure 7-7 shows a flow with SCHED_RR (Round Robin) scheduling.
Figure 7-7. Flow with SCHED_RR Scheduling
DBCBCA
All four threads are timesliced. Threads with higher priority are generally scheduled
when more than one thread is ready to run; however, to ensure fairness, all threads are
given some time. The effective priority of threads may be modified over time by the
scheduler, depending on the use of processor resources.
Thread D executes until it waits or terminates, then threads B and C are timesliced
because they both have middle priority, then thread A executes.
Figure 7-8 shows a flow with SCHED_OTHER (default) scheduling.
Figure 7-8. Flow with SCHED_OTHER Scheduling
DBCABC. . . . . . .
Thread D executes until it waits or terminates; then threads B, C, and A are timesliced,
even though thread A has a lower priority than the other two. Thread A receives less
execution time than thread B or C if either is ready to execute as often as thread A is.
However, the default scheduling policy protects thread A against being blocked from
executing indefinitely.
Because low-priority threads eventually run, the default scheduling policy protects
against the problem of priority inversion discussed in Chapter 8.
124245 Tandem Computers Incorporated 7 15