首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >是否继承了进程优先级?

是否继承了进程优先级?
EN

Stack Overflow用户
提问于 2009-03-06 16:46:32
回答 3查看 3.5K关注 0票数 2

假设您有一个运行优先级为AboveNormal的Windows进程A,该进程启动另一个没有指定优先级的进程B。进程B的优先级是否继承自进程A的优先级?那么,进程B的优先级是什么呢?AboveNormal、Normal或其他?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2010-09-26 23:50:04

如果未指定,则优先级类继承的,在某些情况下。

当调用进程位于IDLE_PRIORITY_CLASSBELOW_NORMAL_PRIORITY类中时,就会发生这种情况。否则,除非在CreateProcess调用期间指定,否则将获取NORMAL_PRIORITY_CLASS

MSDN在CreateProcess的dwCreationFlags上说:

此参数还控制新进程的优先级,该优先级用于确定进程线程的调度优先级。有关值的列表,请参见GetPriorityClass。如果没有指定优先级类标志,则除非创建进程的优先级类是IDLE_PRIORITY_CLASS或BELOW_NORMAL_PRIORITY_CLASS,否则优先级类默认为NORMAL_PRIORITY_CLASS。在这种情况下,子进程接收调用进程的默认优先级。

因此,答案是普通优先级类。基本上,任何高于正常的东西都不会传递给孩子。

票数 7
EN

Stack Overflow用户

发布于 2009-03-06 16:55:43

来自CreateProcess的文档

代码语言:javascript
运行
复制
 The flags that control the priority class and the creation of the process. For a list of values, see Process Creation Flags. 

 This parameter also controls the new process's priority class, which is used to determine the scheduling priorities of the process's threads. For a list of values, see GetPriorityClass. If none of the priority class flags is specified, the priority class defaults to NORMAL\_PRIORITY\_CLASS unless the priority class of the creating process is IDLE\_PRIORITY\_CLASS or BELOW\_NORMAL\_PRIORITY\_CLASS. In this case, the child process receives the default priority class of the calling process. 

中的

dwCreationFlags因此,在您的示例中,新进程将具有正常的优先级。

票数 0
EN

Stack Overflow用户

发布于 2009-03-06 16:57:20

在Windows进程中,优先级不是继承的。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/619543

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档