Search code examples
linuxlinux-kernelschedulerps

rtprio and pri values range in Linux ps


I generate a normal process and check with cmd:

ps -p [PID] -o uname, cmd, cls, pri, rtprio

and have result

USER   CMD     CLS  PRI RTPRIO

haivo  ./pro1  TS   17    -

as far as I know Linux just know priority from 0 - 139 and priority from 0-99 for realtime process, but RTPRIO not show "rt" which means that my process just a normal process, another way pri = 17 belongs realtime priority range while my process just normal process. There seems to be a conflict.


Solution

  • You should focus on CLS-field of ps's output. From man ps:

    CLS class of the process. (alias policy, cls).

    - not reported

    TS SCHED_OTHER

    FF SCHED_FIFO

    ...

    The ranges you talk about are from different scopes. The priority in SCHED_OTHER (SCHED_NORMAL) is often about the PR = 20 + NI formula, where NI is "nice" (between -20 and 19). But keep in mind - the formula is not always relevant, Linux kernel can change the priority on its own logic (but "nice" will remain the same, it's just a hint for kernel).

    Thus, the value you see is absolutely correct.

    See also: Very useful post about Linux nice and prio