Analyzing Processor Activity

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 such cases, it is best to add processor capacity.

Figure 29.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 CpuStress.)

Cc958309.fned96(en-us,TechNet.10).gif

Figure 29.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 29.22 shows two threads of the same process running on a single-processor computer. Figures 29.23, 29.24, and 29.25 provide more detail about how processor usage by threads of CpuStress changed in relation to each threads priority.

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

Cc958309.fned95(en-us,TechNet.10).gif

Figure 29.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 29.23.

Cc958309.fned94(en-us,TechNet.10).gif

Figure 29.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 29.24. Total processor usage is consistently and extremely high.

Cc958309.fned93(en-us,TechNet.10).gif

Figure 29.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 29.25.

Cc958309.fned92(en-us,TechNet.10).gif

Figure 29.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.