Linux priority and nice value

来源:互联网 发布:crm软件哪个好 编辑:程序博客网 时间:2024/05/21 06:50

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.


原创粉丝点击