1

top shows a priority of 20 for most processes, including (for example firefox-bin).

Whilst ps -o pid,lwp,pri,nice,start,stat,bsdtime,cmd,comm -C firefox-bin shows:

  PID   LWP PRI  NI  STARTED STAT   TIME CMD                         COMMAND
 9798  9798  19   0 14:03:47 Sl     2:17 /opt/firefox/firefox        firefox-bin

Since both top & ps are ancient commands, this seems unlikely to be a bug. Why the discrepancy?

6
  • Does this answer your question? What is the difference between ps and top command?
    – taliezin
    Oct 9 '20 at 15:19
  • @taliezin, that suggested duplicate says nothing about the priority value displayed in each command. Oct 9 '20 at 15:23
  • The ps command displays a snapshot of typically just one process, whilst top is typically used to repeatedly display many processes and their effect on machine load. Oct 9 '20 at 15:29
  • 1
    @user4556274, I see, so this might be helpful.
    – taliezin
    Oct 9 '20 at 15:30
  • So its a reported issue? It seems a process can have many priorities... Oct 9 '20 at 15:42
2

They do so because they're different programs.

1

Looks like top shows priority as 20 + nice value but ps shows 19 - nice value so both shows priority as value from 0 to 39 but in top 0 means highest priority but in ps 39 means highest priority.

I'm not sure why is this different and it is possible this is a bug in ps because its man page says "Higher number means lower priority."

2
  • If I use ps -o pri then this statement is also true, but as @user431397 points out, I am using the wrong kind of priority. Oct 9 '20 at 16:00
  • 1
    Interesting, ps manpage mentions only pri (and rprio for real time priority) not priority option/column. Oct 9 '20 at 16:07

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.