Run a process with real-time FIFO priority using chrt -f 80
Start a program under SCHED_FIFO priority 80 with chrt on Linux 6.12, confirm the policy, and know the throttle that stops a runaway task freezing the box.
A latency-sensitive task wants to run as soon as it is ready and not be preempted by ordinary work. The SCHED_FIFO policy gives it that: a runnable task at a higher priority always runs before any normal task, and keeps the CPU until it blocks or yields.
sudo chrt -f 80 ./controllerConfirm the policy of a running process with the -p option. This starts a shell under SCHED_FIFO and asks about itself:
sudo chrt -f 80 sh -c 'chrt -p $$'pid 4242's current scheduling policy: SCHED_FIFO
pid 4242's current scheduling priority: 80The process id will differ. Priorities for real-time policies run from 1 to 99, higher is stronger, and a reasonable approach is to stay out of the very top, which kernel threads use for critical work.
The dangerous part is a loop that never blocks. A SCHED_FIFO task with a bug that spins would starve everything below it on that CPU, including the shell you would use to stop it. The kernel limits this with a real-time throttle, kernel.sched_rt_runtime_us, which defaults to 950000 microseconds in every 1000000: the real-time class gets 95 per cent of each second and the rest goes to normal tasks. Do not set it to -1 on a machine you cannot reach physically.
Starting a real-time task needs CAP_SYS_NICE or a suitable RLIMIT_RTPRIO. See chrt(1) and the kernel scheduler documentation. For work that must not share a core at all, combine it with CPU isolation.