Testing Priority Changes

The previous sections described changing thread priority so that, under bottleneck conditions, threads can run more efficiently. Unfortunately, when processor capacity is already stretched to its limit, boosting priorities of blocked threads might not eliminate or reduce processor bottlenecks. In this case, it is best to add processor capacity.

Figure 7.21 shows threads of different priorities contending for processor time. It demonstrates the changing distribution of processor time among processes of different priorities as demand for processor time increases. (This test was conducted using the utility CPU Stress.)

Cc938614.FNED96(en-us,TechNet.10).gif

Figure 7.21 CPU Time Allocation to Threads Based on Priorities

This chart shows two threads of the same process running on a single-processor computer. Notice the values for processor time for the _Total instance and for threads 1 and 2.

Figure 7.22 shows two threads of the same process running on a single-processor computer. Figures 7.23, 7.24, and 7.25 provide more detail about how processor usage by threads of CPUStres changed in relation to each thread's priority.

In Figure 7.22, the two threads running CPUStres start out at the same low level of activity and run at the same priority—Normal.

Cc938614.FNED95(en-us,TechNet.10).gif

Figure 7.22 Comparison of Threads at Normal Priority

Then, if you increase the priority of Thread 1 to Above Normal, and increase its activity level to moderate, you should notice a slight drop in CPU time for Thread 2, as shown in Figure 7.23.

Cc938614.FNED94(en-us,TechNet.10).gif

Figure 7.23 Comparison of Threads at Normal and Above Normal Priority

Resetting priority for both threads to Normal while running at a higher rate of activity causes each process to consume a large share of processor time, as shown in Figure 7.24. Total processor usage is consistently and extremely high.

Cc938614.FNED93(en-us,TechNet.10).gif

Figure 7.24 Comparison of Normal-Priority Threads Under Slightly Different Loads

Finally, raising the priority level of Thread 1 to Above Normal while maintaining its heightened level of activity results in a much greater allocation of processor time to the higher-priority thread and a dramatic drop in processor time for Thread 2, as shown in Figure 7.25.

Cc938614.FNED92(en-us,TechNet.10).gif

Figure 7.25 Normal Threads Under Substantially Different Loads

These results demonstrate that when the processor has extra capacity, increasing the priority of one thread has little effect on the processor time allotted to each of the competing threads. However, when the processor is at its busiest, increasing the priority of one of the threads, even by one priority level, causes the higher-priority thread to get the vast majority of processor time.

In fact, when all processor time is consumed, Thread 2 might not have been scheduled at all were it not for priority boosts. Windows 2000 uses priority boosts to give processor time to lower-priority ready threads that would not otherwise be able to run. This is especially useful when a thread in low priority is waiting for an I/O operation.