Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Why does unix ps -l whows one number in column "PRI" but in same time ps -o pri shows another number?

P.S. cpu and nice are zero for those processes

share|improve this question

migrated from stackoverflow.com May 21 '11 at 18:08

This question came from our site for professional and enthusiast programmers.

add comment

1 Answer

up vote 3 down vote accepted

In linux procps, the column labeled "PRI" in ps -l is -o opri. Examining output.c shows half a dozen different priority output types:

// "priority"         (was -20..20, now -100..39)
// "intpri" and "opri" (was 39..79, now  -40..99)
// "pri_foo"   --  match up w/ nice values of sleeping processes (-120..19)
// "pri_bar"   --  makes RT pri show as negative       (-99..40)
// "pri_baz"   --  the kernel's ->prio value, as of Linux 2.6.8     (1..140)
// "pri"               (was 20..60, now    0..139)
// "pri_api"   --  match up w/ RT API    (-40..99)

Show all of them with:

ps -o pid,priority,opri,pri_foo,pri_bar,pri_baz,pri,pri_api,comm

  PID PRI PRI FOO BAR BAZ PRI API COMMAND
 2201  20  80   0  21 120  19 -21 zsh
 2762  30  90  10  31 130   9 -31 cat
 2826  20  80   0  21 120  19 -21 ps

(cat is nice cat /dev/zero > /dev/null)

The -o pri value is not suitable for the UNIX standard's "PRI" column, since higher numbers must mean lower priority, so it is not used. I believe these two columns are copied from solaris. The -o pri column is used internally for the "PRI" column of ps -lc.

share|improve this answer
    
Thanks a lot! –  Grook May 21 '11 at 18:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.