注意!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
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步