Chapter 39. Setting the priority for a process with the chrt utility
You can set the priority for a process using the chrt utility.
Prerequisites
- You have administrator privileges.
39.1. Setting the process priority using the chrt utility Copy linkLink copied to clipboard!
The chrt utility checks and adjusts scheduler policies and priorities. It can start new processes with the desired properties, or change the properties of a running process.
Procedure
To set the scheduling policy of a process, run the
chrtcommand with the appropriate command options and parameters. In the following example, the process ID affected by the command is1000, and the priority (-p) is50.chrt -f -p 50 1000
# chrt -f -p 50 1000Copy to Clipboard Copied! Toggle word wrap Toggle overflow To start an application with a specified scheduling policy and priority, add the name of the application, and the path to it, if necessary, along with the attributes.
chrt -r -p 50 /bin/my-app
# chrt -r -p 50 /bin/my-appCopy to Clipboard Copied! Toggle word wrap Toggle overflow For more information about the
chrtutility options, see The chrt utility options.
39.2. The chrt utility options Copy linkLink copied to clipboard!
The chrt utility options include command options and parameters specifying the process and priority for the command.
Policy options
- -f
-
Sets the scheduler policy to
SCHED_FIFO. - -o
-
Sets the scheduler policy to
SCHED_OTHER. - -r
-
Sets the scheduler policy to
SCHED_RR(round robin). - -d
-
Sets the scheduler policy to
SCHED_DEADLINE. - -p n
Sets the priority of the process to n.
When setting a process to SCHED_DEADLINE, you must specify the
runtime,deadline, andperiodparameters.For example:
chrt -d --sched-runtime 5000000 --sched-deadline 10000000 --sched-period 16666666 0 video_processing_tool
# chrt -d --sched-runtime 5000000 --sched-deadline 10000000 --sched-period 16666666 0 video_processing_toolCopy to Clipboard Copied! Toggle word wrap Toggle overflow where
-
--sched-runtime 5000000is the run time in nanoseconds. -
--sched-deadline 10000000is the relative deadline in nanoseconds. -
--sched-period 16666666is the period in nanoseconds. -
0is a placeholder for unused priority required by thechrtcommand.
-