5

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

halp
  • 2,098
  • 1
  • 19
  • 13

3 Answers3

10

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

Jon Ericson
  • 855
  • 10
  • 20
Aslan
  • 101
  • 1
  • 3
  • 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 '15 at 13:40
2

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,591
  • 8
  • 6
  • 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 '10 at 06: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 '10 at 06:25
  • There's also SCHED_IDLE. – Ken Sharp Dec 18 '15 at 13:41
0

In few words:

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

I remember that renice +19 had 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.

Frank Puck
  • 119
  • 4