gpt4 book ai didi

linux - 为什么 niceness 值与进程优先级成反比?

转载 作者:IT王子 更新时间:2023-10-29 00:20:54 28 4
gpt4 key购买 nike

niceness进程的优先级随着进程优先级的增加而降低。

摘自《Linux 编程入门》第 4 版,第 169 页:

The default priority is 0. Positive priorities are used for background tasks that run when no other higher priority task is ready to run. Negative priorities cause a program to run more frequently, taking a larger share of the available CPU time. The range of valid priorities is -20 to +20. This is often confusing because the higher the numerical value, the lower the execution precedence.

是否有任何特殊原因导致负值对应于更高的进程优先级(而不是为更高的 niceness 值进程增加优先级)?

最佳答案

@Ewald 的回答是正确的,Jerry Peek 等人Unix Power Tools(O'Reilly,2007 年,第 507 页)中证实了这一点:

This is why the nice number is usually called niceness: a job with a high niceness is very kind to the users of your system (i.e., it runs at low priority), while a job with little niceness hogs the CPU. The term "niceness" is awkward, like the priority system itself. Unfortunately, it's the only term that is both accurate (nice numbers are used to compute the priorities but are not the priorities themselves) and avoids horrible circumlocutions ("increasing the priority means lowering the priority...").

至少从 V6 Unix 开始,Nice 就有了这个含义。 ,但 V6 手册从未明确解释这一点。允许值的范围是 -220 到 +20,为 super 用户保留负数。在 V7 中,范围更改为 -20 到 +20 .

关于linux - 为什么 niceness 值与进程优先级成反比?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14067128/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com