6

What is the difference between renice and chrt commands in Linux?

halp
  • 2,528

3 Answers3

12

Well, I found this on http://www.spinics.net/lists/linux-rt-users/msg03987.html which explains the difference pretty nicely:

"nice" is an historic utility which was used in the early days of batch computing to be "nice" to other users and give up some CPU time. It's still in use and useful and applies only to processes which run with the SCHED_OTHER policy on Linux.

"chrt" is a tool to change scheduling policy (SCHED_OTHER, SCHED_FIFO, SCHED_RR) and the priority of a process/task. With chrt you can either start a process with such a policy or modify an already running process/tasks policy. You need to have the permissions to do that.

So the main difference is that "nice" can only operate within the nice levels of the SCHED_OTHER policy while "chrt" can change the policy and the priority of a process/task.

...

tglx

Aslan
  • 121
  • 1
  • 3
3

chrt(1) is used not only to change the priority of a process, but also the scheduling policy. The scheduling policy can be four:

  • SCHED_FIFO=first in, first out, real time processes.
  • SCHED_RR=round robin real time processes.
  • SCHED_OTHER=normal time sharing
  • SCHED_BATCH=almost the same as the SCHED_OTHER, but the process is considered always the most cpu consuming.

See setscheduler(2).

renice(8) just change the priority of a process.

PiL
  • 1,609
1

In few words:

renice does not have an effect detectible by humans but chrt does.

I remember that renice +19 used to have an effect on SUNOS -- but SUN "fixed" this, probably because people complained about it having an effect.

Decades ago I was complaining about such a feature not being available on any UNIXs (but on Windows) and the notion was rejected by various UNIX gurus -- UNIX being perfect as it was already.

The main application area of chrt is to start processes with idle scheduling class. This is supposed to allow one to start CPU-intensive non-interactive processes without much effecting processes running with other (normal) scheduling classes -- means a parallel build should not cause the video player to stutter.

Later edit: At least on centos 7.9 processes running with idle priority class are still preempting processes running with normal priority class. So I might have to reverse my above statement above that chrt has an effect whereas renice/nice has not. Both seem to be equally useless.

Frank Puck
  • 129
  • 4