2. Basic Priority Levels
• The following are priority levels within each priority class:
• THREAD_PRIORITY_IDLE
• THREAD_PRIORITY_LOWEST
• THREAD_PRIORITY_BELOW_NORMAL
• THREAD_PRIORITY_NORMAL
• THREAD_PRIORITY_ABOVE_NORMAL
• THREAD_PRIORITY_HIGHEST
• THREAD_PRIORITY_TIME_CRITICAL
3. • All threads are created using THREAD_PRIORITY_NORMAL. This means that
the thread priority is the same as the process priority class. After you create a
thread, use the SetThreadPriority() function to adjust its priority relative to other
threads in the process.
• A typical strategy is to use THREAD_PRIORITY_ABOVE_NORMAL or
THREAD_PRIORITY_HIGHEST for the process's input thread, to ensure that
the application is responsive to the user.
• Background threads, particularly those that are processor intensive, can be set
to THREAD_PRIORITY_BELOW_NORMAL or THREAD_PRIORITY_LOWEST,
to ensure that they can be preempted when necessary.
• However, if you have a thread waiting for another thread with a lower priority to
complete some task, be sure to block the execution of the waiting high-priority
thread.
• This is preferable to having the thread execute a loop. Otherwise, the process
may become deadlocked, because the thread with lower priority is never
scheduled.
4. • Internally Windows uses 32 priority levels
ranging from 0 to 31
• They are divided into 2 groups
o Fifteen Variable Levels (Levels 0 - 15)
o Sixteen Realtime Levels (Levels 16 - 31)
o Normally processes base priority is usually set to default i.e at the
middle of it’s priority group/ range ( 24 , 13 , 10 , 8 , 6 , 4 ) .
o We can view priorities through Windows Performance Monitor, WinDbg
(Windows Debugging Utility) or a external Process Explorer.
o We can change the base priority using Task Manager ( taskmgr.exe ) or
a Process Explorer.
5. Variable Levels
Thread Base Process Priority Process Priority Process Priority Process Priority Process Priority
Priority Idle Below Normal Normal Above Normal High
0
1 Idle Idle Idle Idle Idle
2 Lowest
3 Below Normal
4 Normal Lowest Background
5 Above Normal Below Normal
6 Highest Normal Lowest
7 Above Normal Below Normal
8 Highest Normal Lowest
9 Above Normal Below Normal
10 Highest Normal
11 Above Normal Lowest
12 Highest Below Normal
13 Normal
14 Above Normal
15 Time Critical Time Critical Time Critical Time Critical
Time Critical
Highest
6. Realtime
Levels
Thread Base Process Priority
Priority Reatime
16 Idle
17
18
19
20
21
22 Lowest
23 Below Normal
24 Normal
25 Above Normal
26 Time Critical
27
28
29
30
31 Highest