进程的priority和nice

本文选自Difference between nice value and priority in the top output,以Linux系统为例讲解进程的prioritynice
(1)

The difference is that PR is a real priority of a process at the moment inside of the kernel and NI is just a hint for the kernel what the priority the process should have.

Priority反映当时进程真正的优先级,而nice则是告诉kernel进程应该获得什么样的优先级。

(2)Nice的值从-2019-20表示优先级最高。通常情况下,priority = nice + 20,也就是priority的值为0~39。但是上述理论仅仅适用于调度策略是SHED_OTHER的进程,此外,kernel也有可能只改变priority的值,而nice的值保持不变,因此上述等式同样不适用。

发表评论

邮箱地址不会被公开。 必填项已用*标注

This site uses Akismet to reduce spam. Learn how your comment data is processed.