注意!GetThreadPriority的返回值不是系统的优先级值
GetThreadPriority的返回值
系统的优先级值
windows核心编程 5th 184页
| Return code/value | Description |
|---|---|
|
Priority 1 point above the priority class. |
|
Priority 1 point below the priority class. |
|
Priority 2 points above the priority class. |
|
Base priority of 1 for IDLE_PRIORITY_CLASS, BELOW_NORMAL_PRIORITY_CLASS, NORMAL_PRIORITY_CLASS, ABOVE_NORMAL_PRIORITY_CLASS, or HIGH_PRIORITY_CLASSprocesses, and a base priority of 16 forREALTIME_PRIORITY_CLASS processes. |
|
Priority 2 points below the priority class. |
|
Normal priority for the priority class. |
|
Base-priority level of 15 for IDLE_PRIORITY_CLASS, BELOW_NORMAL_PRIORITY_CLASS, NORMAL_PRIORITY_CLASS,ABOVE_NORMAL_PRIORITY_CLASS, or HIGH_PRIORITY_CLASSprocesses, and a base-priority level of 31 forREALTIME_PRIORITY_CLASS processes. |
| Process priority class | Thread priority level | Base priority | |
|---|---|---|---|
| IDLE_PRIORITY_CLASS | THREAD_PRIORITY_IDLE | 1 | |
| THREAD_PRIORITY_LOWEST | 2 | ||
| THREAD_PRIORITY_BELOW_NORMAL | 3 | ||
| THREAD_PRIORITY_NORMAL | 4 | ||
| THREAD_PRIORITY_ABOVE_NORMAL | 5 | ||
| THREAD_PRIORITY_HIGHEST | 6 | ||
| THREAD_PRIORITY_TIME_CRITICAL | 15 | ||
| BELOW_NORMAL_PRIORITY_CLASS | THREAD_PRIORITY_IDLE | 1 | |
| THREAD_PRIORITY_LOWEST | 4 | ||
| THREAD_PRIORITY_BELOW_NORMAL | 5 | ||
| THREAD_PRIORITY_NORMAL | 6 | ||
| THREAD_PRIORITY_ABOVE_NORMAL | 7 | ||
| THREAD_PRIORITY_HIGHEST | 8 | ||
| THREAD_PRIORITY_TIME_CRITICAL | 15 | ||
| NORMAL_PRIORITY_CLASS | THREAD_PRIORITY_IDLE | 1 | |
| THREAD_PRIORITY_LOWEST | 6 | ||
| THREAD_PRIORITY_BELOW_NORMAL | 7 | ||
| THREAD_PRIORITY_NORMAL | 8 | ||
| THREAD_PRIORITY_ABOVE_NORMAL | 9 | ||
| THREAD_PRIORITY_HIGHEST | 10 | ||
| THREAD_PRIORITY_TIME_CRITICAL | 15 | ||
| ABOVE_NORMAL_PRIORITY_CLASS | THREAD_PRIORITY_IDLE | 1 | |
| THREAD_PRIORITY_LOWEST | 8 | ||
| THREAD_PRIORITY_BELOW_NORMAL | 9 | ||
| THREAD_PRIORITY_NORMAL | 10 | ||
| THREAD_PRIORITY_ABOVE_NORMAL | 11 | ||
| THREAD_PRIORITY_HIGHEST | 12 | ||
| THREAD_PRIORITY_TIME_CRITICAL | 15 | ||
| HIGH_PRIORITY_CLASS | THREAD_PRIORITY_IDLE | 1 | |
| THREAD_PRIORITY_LOWEST | 11 | ||
| THREAD_PRIORITY_BELOW_NORMAL | 12 | ||
| THREAD_PRIORITY_NORMAL | 13 | ||
| THREAD_PRIORITY_ABOVE_NORMAL | 14 | ||
| THREAD_PRIORITY_HIGHEST | 15 | ||
| THREAD_PRIORITY_TIME_CRITICAL | 15 | ||
| REALTIME_PRIORITY_CLASS | THREAD_PRIORITY_IDLE | 16 | |
| THREAD_PRIORITY_LOWEST | 22 | ||
| THREAD_PRIORITY_BELOW_NORMAL | 23 | ||
| THREAD_PRIORITY_NORMAL | 24 | ||
| THREAD_PRIORITY_ABOVE_NORMAL | 25 | ||
| THREAD_PRIORITY_HIGHEST | 26 | ||
| THREAD_PRIORITY_TIME_CRITICAL | 31 | ||
Windows并没有提供返回线程优先级的函数。这一遗漏是Microsoft故意的。请记住Microsoft保留了任何时候改变调度算法的权利。我们设计的应用程序不应该了解调度算法具体细节。如果我们始终使用进程优先级类和相对线程优先级,那么我们的应用程序在现在和在操作系统的未来版本都可以运行得很好。参考资源: GetThreadPriority function Scheduling Priorities

浙公网安备 33010602011771号