Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


October 1998

How Windows NT Dispatches Processes and Threads


RSS
Subscribe to Windows IT Pro | See More Scalability Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!
Main Article    Tuning Multiprocessor Configurations

A process is an instance of an application or system program that runs on a system. Examples of processes are winword.exe (Microsoft Word for Windows), lsass.exe (Windows NT's local security administration subsystem), and timeserv.exe (from Microsoft Windows NT Server 4.0 Resource Kit). A thread is a unit of work that can execute simultaneously with other units of work on the system. Some threads create (or spawn) other threads. A process is simply a collection of threads. A thread is an executable part of a process.

The NT dispatcher determines the order in which threads run and on which processors they run. Affinity is the tendency for a thread to run on a particular processor or set of system processors. NT uses soft affinity by default, running a thread on the same processor it ran on previously. NT also supports hard affinity to let you specify which processors a process or thread uses. Ideal affinity or preferred affinity lets you specify a preferred processor from the group of hard affinity processors. The NT dispatcher runs a process on the preferred processor if that processor is available. NCR's SMP Utilization Manager lets you set hard affinity and preferred affinity for process threads. Thus, a process can run on only a few processors, and the other processors remain free to run other processes.

For more information about processes and threads, see Christa Anderson, "Foreground Application Handling in NT 4.0," June 1997. For more information about the NT scheduler, see Mark Russinovich, "Inside the Windows NT Scheduler, Part 1," July 1997, and "Inside the Windows NT Scheduler, Part 2," August 1997.

The Scheduler
The NT scheduler maintains a prioritized list of scheduled threads and dispatches the highest priority threads first. Each thread has a priority of 0 to 31. These priority values belong to priority classes: Real Time, Very High, Normal, and Idle. Within priority classes, a thread has a priority level: Highest, Above Normal, Normal, Below Normal, or Idle. These priority levels range from 2 points above to 2 points below the normal priority level.

When NT dispatches a thread, it assigns a CPU for a particular length of time. Realtime priority threads are an exception. These threads run until they complete or until they must stop to wait for another event. When a thread's time limit expires, the dispatcher moves to the next thread in the list.

NT treats less-CPU-intensive threads equally. It gives proportionately more CPU time to applications that consist of many threads than it gives to applications with fewer threads. NT lowers the priority of CPU-intensive threads to give priority to less-CPU-intensive tasks. This process creates problems if you need to execute a CPU-intensive application quickly. SMP Utilization Manager lets you allocate the necessary CPU time to give priority to either type of application.

In a symmetric multiprocessing (SMP) system, the dispatcher selects a processor to run a thread. The dispatcher first selects the thread's ideal processor. If the ideal processor is unavailable, the dispatcher selects the processor the thread ran on previously. If neither processor is available, the dispatcher selects another idle processor or a processor running a lower-priority thread.

Processor Cache Efficiency and Application CPU Requirements
NT typically runs a thread on the processor that ran the thread previously. When a process uses a processor repeatedly, the processor's cache memory stores the most commonly used instructions. The processor can then execute a process without having to retrieve the instructions from system RAM. Cache pollution occurs when a processor runs a new process and the second process' instructions overwrite the first process' instructions. If you have numerous processors in a busy multiple-application system, a thread rarely runs on the same processor each time.

In large multiprocessor systems running multiple applications, applications' CPU requirements are often stable. Thus, you can determine CPU requirements for each application. Suppose you have an 8-way system running SQL Server and Exchange Server, and Performance Monitor shows that SQL Server uses three times as many CPU cycles as Exchange uses. You can use SMP Utilization Manager to set hard CPU affinity, designating six processors to run SQL Server and two processors to run Exchange. Setting processor affinity improves the chance that the same processor or processors will repeatedly execute a process and thus reduces the instances of processor cache reload. Likewise, preventing an application from using certain processors ensures that the application cannot hog CPU time. Without hard CPU affinity settings, the dispatcher can select any system processor and perhaps produce cache pollution and suboptimal performance.

End of Article



Reader Comments

You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Friday at PASS Europe 2006

Kevin talks about the closing day of the event and shares a funny Microsoft film. ...

PsExec

This freeware utility lets you execute processes on a remote system and redirect output to the local system. ...

Escape From Yesterworld

Kevin points you to the funniest SQL Server website ever! ...


Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Related Events Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing