Partitioning threads to specific processors is called setting a processor affinity mask The affinity mask contains bits for each processor on the system, defining which processors a particular process or thread can use. When you set affinity for a process to a particular processor, all threads of the process inherit the affinity to the same processor.
Windows 2000 uses soft processor affinity, determining automatically which processor should service threads of a process. The soft affinity for a thread is the last processor on which the thread was run or the ideal processor of the thread. The Windows 2000 soft affinity thread scheduling algorithm enhances performance by improving the locality of reference. However, if the ideal or previous processor is busy, soft affinity allows the thread to run on other processors, allowing all processors to be used to capacity.
Windows 2000 also provides hard affinity, meaning that the processor affinity mask restricts the threads affected by the affinity mask to the processors specified by the mask. Threads restricted by a hard affinity mask will not run on processors that aren't included in the affinity mask. Hard affinity used with partitioning can improve performance of an SMP system substantially. However, be cautious when using hard affinity because it might cause the processors to have uneven loads. If processes that have had their affinity set to a specific processor are causing high CPU utilization on that processor while other processors on the system have excess processing capacity, the processes for which a hard affinity has been set might run slower because they cannot use the other processors.
If you want to ensure that a particular process or application doesn't have to share processing power with other tasks, you can use hard affinity to dedicate that process to one processor, leaving the remaining ones available for other work. This is easy to do using the Set Affinity command in Task Manager. For more information on Task Manager, see "Overview of Performance Monitoring" in this book.
Figure 10.3 shows the user interface for setting processor affinity.
Figure 10.3 Processor Affinity Dialog Box in Task Manager
Another processor-partitioning option would be to divide discrete work items, such as tables in a database, among different processors. Consult the documentation accompanying your database software for information on partitioning databases for optimum performance.
Using functions in the Platform SDK, application developers who create applications using job objects can specify that all processes associated with the job object use the same processor affinity.