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

标签 linux unix terminology nice

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/

相关文章:

linux - Unix 排序中的奇怪字符串比较

linux - 如何将 dig 命令的输出打印到文本文件

linux - 在 MacOS 终端中,是否可以返回到上一个目录(多次)。 (例如像 cd - 但返回多次)

unix - 如何使用mv命令在UNIX中重命名多个文件?

java - 编码和序列化

cuda - 高性能计算术语 : What's a GF/s?

linux - Inotify 监听 moved_from/moved_to 事件

python - 导入错误 : No module named pytesseract

Java unix 过滤器

javascript - 什么是 JSONP,为什么要创建它?