Linux priority and nice value

本文详细解释了Linux中进程优先级与nice值的概念,包括它们的范围、类型以及如何通过nice命令调整普通进程为实时进程,以及nice值与PR值看起来不同的原因。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

From http://www.sadikhov.com/forum/index.php?/topic/56043-difference-between-priority-and-nice-value/

 

The truth is that there are 140 prioroty numbers 0-139 but 0-99 or the first 100 are realtime process prioroties
and 100-139 are regular user process prioroties. you can see the real time prioroties by typing "chrt"
eg: chrt -m
SCHED_FIFO min/max priority : 1/99
SCHED_RR min/max priority : 1/99
SCHED_OTHER min/max priority : 0/0

The values that you commonly change using the nice command -20 to +19 are infact
prioroties 100 to 139. You can schedule a regular process to run with a real time prioroty.
eg chrt -p 55 5831 will run process 5831 with a real time prioroty of 56 (between 0 and 139).
The fact you get numbers like 34 (134) reported back is because of POSIX compliance.

So your nice value and PR value will often look different because of the kernels dynamiic recource
allocation adjustment. Sometimes adjusting multimedia processes on your system to run
as realtime is usefull if your sytem is busy doing lot's of thing and your mp3's or videos are 
skipping or are not able to keep up.

If a top command reports ... 6101 root 15 0 34336 6844 4968 S 5.3 1.3 0:00.16 xmms 
it means that the nice value is 0 (120) and the user prioroty is 15 (120 - 100).


you would think that the PR should be 20 because 120 -100 = 20, so why is the user PR 15?
Because the kernel can dynamically change the user PR depending on how interactive it is
and in this case the kernel has given a prioroty of 15 (-5) to the process due to the interactive nature
of the xmms music player. I think RT means Real Time process.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值