进程优先级是继承的吗?
想象一下,您有一个以高于正常优先级运行的 Windows 进程 A,它启动了另一个进程 B,但没有指定优先级。 进程B的优先级是继承进程A的优先级吗? 那么,进程B的优先级是什么? 高于正常、正常还是其他?
Imagine that you have a Windows process A running with priority AboveNormal that starts another process B without specify the priority. Is the priority of the process B inherited from the priority of the process A? So, what will be the priority on the process B? AboveNormal, Normal, or another?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果未指定,则在某些情况下会继承优先级类别。
当调用进程属于 IDLE_PRIORITY_CLASS 或 BELOW_NORMAL_PRIORITY 类时,会发生这种情况。 否则,除非在 CreateProcess 调用期间指定,否则它将获得 NORMAL_PRIORITY_CLASS。
MSDN 在 CreateProcess 的 dwCreationFlags 上说:
因此答案是 NORMAL 优先级。 基本上任何超出正常水平的东西都不会遗传给孩子。
If not specified, the priority class is inherited, in some cases.
It occurs when the calling process is in the IDLE_PRIORITY_CLASS or BELOW_NORMAL_PRIORITY class. Otherwise, it gets NORMAL_PRIORITY_CLASS unless specified during the CreateProcess call.
MSDN says on dwCreationFlags of CreateProcess:
The answer is therefore NORMAL priority class. Basically anything that is above normal doesn't get passed to the child.
来自 CreateProcess 的文档:
因此,在您的示例中,新进程将具有正常优先级。
From the documentation for CreateProcess:
So, in your example, the new process would have normal priority.
在 Windows 中,进程优先级是不继承的。
In Windows process priority is not inherited.