Scheduling - RT throttling

Programming failures in real-time applications can cause the entire system to hang. Such a failure could act like a call of a `while(true){}` loop. When the real-time application has the highest possible priority and is scheduled with SCHED_FIFO policy, no other task can preempt it. This leads to the system blocking all other tasks and scheduling this loop with a CPU load of 100 percent. Real-time throttling is a mechanism to avoid such situations by limiting the execution time of real-time tasks per period. The settings are exported into the proc file system. The default settings are:

# cat /proc/sys/kernel/sched_rt_period_us
1000000
# cat /proc/sys/kernel/sched_rt_runtime_us
950000

To reach a only 50% CPU usage for real-time tasks and a larger period the values can be changed with the following commands:

# echo 2000000 > /proc/sys/kernel/sched_rt_period_us
# echo 1000000 > /proc/sys/kernel/sched_rt_runtime_us

Real-time throttling is disabled in case the real-time task runtime has the same length than the the period. This is done automatically by writing `-1` into `sched_rt_runtime_us`:

# echo -1 > /proc/sys/kernel/sched_rt_runtime_us

This mechanism is already implemented in mainline Linux.

References: