How to start a process with the deadline scheduler (SCHED_DEADLINE)

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 8
  • Red Hat Enterprise Linux 7.6 or later

Issue

  • How to start a process with the SCHED_DEADLINE scheduler

Resolution

To start a process with the SCHED_DEADLINE scheduler use the chrt command with the below sytax:

# chrt -d -T <runtime> -D <deadline> -P <period> 0 <command> <command options>

Or to change scheduling policy for an existing process:

# chrt -d -T <runtime> -D <deadline> -P <period> -p 0 <PID>

The values for runtime, deadline, and period are all integers of nanoseconds, where:

  • Runtime: The execution time allotted to the task
  • Deadline: How soon after the period starts that the runtime must be started
  • Period: How often the runtime will be executed

PLEASE NOTE:

The kernel requires for the following to be true:

  • RUNTIME <= DEADLINE <= PERIOD

Omitting any 1 of the parameters will result in the below:

  • Omitting runtime will cause runtime to be set to the deadline value
  • Omitting deadline will cause deadline to be set to the period value
  • Omitting period will cause period to be set to the deadline value

However, at least deadline or period needs to be specified.

The changes can be confirmed via the chrt command:

# chrt -p <pid>
pid <pid>'s current scheduling policy: SCHED_DEADLINE
pid <pid>'s current scheduling priority: 0
pid <pid>'s current runtime/deadline/period parameters: <runtime>/<deadline>/<period>

Example:

# chrt -d --sched-runtime 1000000 --sched-deadline 5000000 --sched-period 5000000 0 ./test-app &
[1] 8521

# chrt -p 8521
pid 8521's current scheduling policy: SCHED_DEADLINE
pid 8521's current scheduling priority: 0
pid 8521's current runtime/deadline/period parameters: 1000000/5000000/5000000

Alternatively, you can also use appropriate systemcalls or C-lang functions in your source code.
For more information see:

Disclaimer: Links contained herein to external website(s) are provided for convenience only. Red Hat has not reviewed the links and is not responsible for the content or its availability. The inclusion of any link to an external website does not imply endorsement by Red Hat of the website or their entities, products or services. You agree that Red Hat is not responsible or liable for any loss or expenses that may result due to your use of (or reliance on) the external site or content.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments