6

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

3 Answers 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.

4
  • 2
    So chrt is "stronger" than renice? Does it make sense to use chrt and renice together? The manpages look cryptic to me, I'd like to read about some use cases to understand the differences.
    – halp
    Jul 16, 2010 at 6:17
  • If you want to change the priority of a process, just use nice and renice. If you want to change more in detail a property of a process, use chrt.
    – PiL
    Jul 16, 2010 at 6:25
  • There's also SCHED_IDLE.
    – Ken Sharp
    Dec 18, 2015 at 13:41
  • idle class does not know any priorities anymore. So no, one cannot change priorities using renice anymore after having set idle scheduling class.
    – Frank Puck
    Oct 10, 2023 at 13:23
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

1
  • This is definitely the better answer, thanks. You can still set a nice value for processes in policies other than SCHED_OTHER but it shouldn't have an effect. Could be useful if moving processes in and out of scheduler priorities though. There's also SCHED_IDLE.
    – Ken Sharp
    Dec 18, 2015 at 13:40
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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .