psとtopのPRI値が異なるのはなぜですか?

psとtopのPRI値が異なるのはなぜですか?

NginxのPIDは次のとおりです。19910

  1. その価値は19存在するps -eo pri

     ps -eo pid,ppid,ni,pri,psr,pcpu,stat,cmd |head -n1;ps -eo pid,ppid,ni,pri,psr,pcpu,stat,cmd |grep nginx
       PID  PPID  NI PRI PSR %CPU STAT CMD
     19910     1   0  19   0  0.0 Ss   nginx: master process /usr/sbin/nginx
     19911 19910   0  19   2  0.0 S    nginx: worker process
     19912 19910   0  19   1  0.0 S    nginx: worker process
     19914 19910   0  19   1  0.0 S    nginx: worker process
     19915 19910   0  19   0  0.0 S    nginx: worker process
    
  2. その価値は80存在するps -elf

     ps -elf |head -n1;ps -elf |grep nginx
     F S UID        PID  PPID  C PRI  NI ADDR SZ WCHAN  STIME TTY          TIME CMD
     5 S root     19910     1  0  80   0 - 21487 sigsus Jul29 ?        00:00:00 nginx: master process /usr/sbin/nginx
     5 S www-data 19911 19910  0  80   0 - 21576 ep_pol Jul29 ?        00:01:55 nginx: worker process
     5 S www-data 19912 19910  0  80   0 - 21576 ep_pol Jul29 ?        00:02:05 nginx: worker process
     5 S www-data 19914 19910  0  80   0 - 21576 ep_pol Jul29 ?        00:02:00 nginx: worker process
     5 S www-data 19915 19910  0  80   0 - 21576 ep_pol Jul29 ?        00:02:08 nginx: worker process
    
  3. その価値は20存在するtop -b -n 1 -p

     top -b -n 1 -p 19910                              
     top - 09:57:13 up 435 days, 19 min,  2 users,  load average: 0.00, 0.00, 0.00
     Tasks:   1 total,   0 running,   1 sleeping,   0 stopped,   0 zombie
     %Cpu(s):  0.1 us,  0.1 sy,  0.0 ni, 99.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
     KiB Mem:   8175360 total,  4617480 used,  3557880 free,   167444 buffers
     KiB Swap:  8384508 total,    10408 used,  8374100 free.  3955108 cached Mem
    
       PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
     19910 root      20   0   85948   2944   1784 S   0.0  0.0   0:00.00 nginx
    

私の質問は次のとおりです。

  1. 2つの異なるコマンドの出力が完全に異なるのはなぜですかps
  2. これらとPRIの違いは何ですか?pstop

誰かが私に説明していただきありがとうございます。

ベストアンサー1

~によるとこれ:

top印刷された元の値priority、つまりの18番目の列/proc/[pid]/statなので、出力は次のようになります。20

ps -eo pri印刷された値priはと等しい39 - priorityので、出力は次のようになります。39 -20 = 19

ps -l-lオプションで印刷された値opriはと等しい60 + priorityため、出力は '60 + 20 = 80'です。

おすすめ記事