假设您有一个以 AboveNormal 优先级运行的 Windows 进程 A 启动另一个进程 B 而未指定优先级。进程B的优先级是否继承了进程A的优先级?那么,进程 B 的优先级是什么? AboveNormal、Normal 还是其他?
最佳答案
如果未指定,在某些情况下,优先级是继承的。
当调用进程处于IDLE_PRIORITY_CLASS 或BELOW_NORMAL_PRIORITY 类时发生。否则,它将获得 NORMAL_PRIORITY_CLASS,除非在 CreateProcess 调用期间指定。
MSDN 在 CreateProcess 的 dwCreationFlags 上说:
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.
因此答案是 NORMAL 优先级。基本上任何超出正常水平的东西都不会传递给 child 。
关于windows - 进程优先级是否继承?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/619543/