4

In the top and htop tools, processes (or/and threads depending on display settings) having the highest realtime priority (99 from the userland API point of view) with either the scheduling policy SCHED_RR or SCHED_FIFO the priority is displayed as RT.

For all the other real time processes, the priority is displayed as a number p defined by:

p = -userprio -1 

I am wondering why top and htop don't display -100 for higest priority real time processes ?

  • I can confirm that top and htop list four processes with priority = RT: migration/0 migragion/1, watchdog/0 watchdog/1 in my case. However, ps -eo rtprio,comm lists their priority as 99. – Sebastian Sep 10 '14 at 6:47
  • Could you add output of ps -o rtprio,state,pid,comm -A | grep -Ev '^\s+- '? – Volker Siegel Sep 10 '14 at 6:47
  • @VolkerSiegel It outputs the realtime priority from the userland API, i.g. 99 for highest rpriority RT processes. – Manuel Selva Sep 10 '14 at 6:51
6

I am wondering why top and htop don't display -100 for higest priority real time processes ?

That's because SCHED_RR and SCHED_FIFO have fixed static priorities from 1-99:

Source

For realtime priorities, the order is reversed: 99 is indeed the highest one, contrary to the ususal "lower is higher".

Per your comment I misunderstood your question, sorry.

There is only one column in top, so differentiating the RT priorities from the other ones would not be possible. To get around this, "rt" is used to indicate that these processes use a realtime scheduler class.

You can see the difference using ps ax --format uname,pid,ppid,tty,cmd,cls,pri,rtprio, which will give you 2 columns, one for the prio and the other one for rtprio.

Sidenote: The aforementioned command will also show you the scheduler class the process uses.

  • Thanks for the answer but question was not clear: I am wondering why RT is displayed instead of a number – Manuel Selva Sep 10 '14 at 12:52
  • Added some more info to my answer. – Jan Sep 10 '14 at 14:00
  • 1
    Thanks again Jan, but in htop and top only processes with RT prio = 99 are displayed as RT, the other ones even if scheduled with SCHED_FIFO or SCHED_RR are displayed with a number – Manuel Selva Sep 10 '14 at 19:52
  • I even dug through the code of procps-ng, but I didn't find anything... Waiting for someone else to find the solution. – Jan Sep 10 '14 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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