Program Priority and Multithreaded ApplicationsLast reviewed: March 25, 1997Article ID: Q106253 |
The information in this article applies to:
SUMMARYWhen 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 INFORMATIONWhen 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 16The 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
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |