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

Posted on

A server stack is the collection of software that forms the operational infrastructure on a given machine. In a computing context, a stack is an ordered pile. A server stack is one type of solution stack — an ordered selection of software that makes it possible to complete a particular task. Like in this post about What is the difference between renice and chrt commands in Linux? was one problem in server stack that need for a solution. Below are some tips in manage your linux server when you find problem about linux, scheduling, , , .

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

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.

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

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.

Leave a Reply

Your email address will not be published. Required fields are marked *