Microsoft KB Archive/106253

= Program Priority and Multithreaded Applications =

Article ID: 106253

Article Last Modified on 10/31/2006

-

APPLIES TO


 * Microsoft Windows NT Advanced Server 3.1
 * Microsoft Windows NT Workstation 3.1
 * Microsoft Windows NT Advanced Server 3.1
 * Microsoft Windows NT Server 4.0 Standard Edition
 * Microsoft Windows NT Workstation 4.0 Developer Edition

-



This article was previously published under Q106253



SUMMARY
When a program is started under Windows NT, it will have a priority class that is either normal or equal to the priority class specified in the command line when using the START command (Idle, Normal, High, or Realtime). The priority class determines at which priority (from 1 to 31) the program will run. In a multithreaded application, threads spawned by the program can be lower or higher than the current priority class of the program; however, all thread priorities will be relative to the priority class of the parent program. While a program can change its priority class after starting, all of its threads will still have the same relative priority.



MORE INFORMATION
When a process spawns a thread, one of the parameters in the function call sets the thread priority relative to the priority of the parent process. This parameter can have one of the following values: Idle, Lowest, Below Normal, Normal, Above Normal, Highest and Time Critical. The starting priority set for the thread will be based upon that parameter and the current priority of the process starting the thread. The priorities are as follows:

RELATIVE                 PROCESS PRIORITY CLASS THREAD               Normal, in      Normal, in PRIORITY       Idle   Background      Foreground    High    Realtime Time Critical  15        15              15         15        31 Highest         6         9              11         15        26 Above Normal    5         8              10         14        25 Normal          4         7               9         13        24 Below Normal    3         6               8         12        23 Lowest          2         5               7         11        22 Idle            1         1               1          1        16

The table above lists the base priority of a thread, which is set by calling the function SetThreadPriority; however, a thread's priority can change as the thread executes. The system can boost a thread's priority higher as time goes on and then reduce the priority back down to the base, though Windows NT will never reduce a thread lower than its base priority. The system will boost a thread's priority when a user interacts directly with a thread, including mouse and keyboard input or simply bringing the thread to the foreground.

For more information on process priorities, query on the following key words in the WINNT Knowledge Base:

  priority and process

Additional query words: prodnt

Keywords: kbenv KB106253

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.