Free — no signup required

RT Policies: SCHED_FIFO vs. SCHED_RR vs. SCHED_DEADLINE

2 min read

The Three Flavors of Real-Time

1. SCHED_FIFO (First-In, First-Out)
The simplest and most aggressive RT policy.

  • A SCHED_FIFO process runs until it either blocks (e.g., waits for I/O), voluntarily yields (sched_yield()), or is preempted by a higher-priority RT task.
  • There is no time slice. If a SCHED_FIFO priority-50 process is runnable, it runs forever (subject to RT throttling) until one of the above conditions occurs.
  • A bug causing an infinite loop in a SCHED_FIFO process will consume the CPU entirely (minus the RT throttle reserve).
  • Use case: Interrupt handlers, audio servers (like PulseAudio/PipeWire), industrial control loops.

2. SCHED_RR (Round-Robin)
A gentler version of FIFO.

  • Identical to SCHED_FIFO except it has a time quantum (default 100ms, visible in /proc/sys/kernel/sched_rr_timeslice_ms).
  • When a SCHED_RR process exhausts its quantum, it moves to the back of the queue of RT tasks at the same priority level. Higher-priority RT tasks still preempt it immediately.
  • Use case: Multiple RT tasks at the same priority that should share the CPU fairly among themselves.

3. SCHED_DEADLINE
The most sophisticated RT policy, implementing Earliest Deadline First (EDF) scheduling.

  • Each task declares three parameters: runtime (how much CPU it needs per period), deadline (by when it must finish), and period (how often it repeats).
  • Example: "I need 2ms of CPU every 10ms, and I must finish within 8ms of my period start."
  • The kernel performs admission control: it will reject a SCHED_DEADLINE task if accepting it would make existing deadline tasks miss their deadlines.
  • SCHED_DEADLINE tasks have higher priority than SCHED_FIFO and SCHED_RR.
  • Use case: Video encoding pipelines, network packet processing, any workload with known, periodic CPU requirements. In practice, these three parameters are set on a running process via chrt --deadline, which takes the runtime, deadline, and period as arguments (in nanoseconds).
Interview Tip

Interviewers at companies running latency-sensitive infrastructure (trading systems, telco, audio/video) often ask: "What's the difference between SCHED_FIFO and SCHED_DEADLINE?" The key insight is that SCHED_FIFO gives you priority but no timing guarantees — you still have to manage your own timing logic. SCHED_DEADLINE gives the kernel enough information to mathematically guarantee that deadlines are met, and it will refuse to admit tasks that would cause deadline misses. This is the difference between "probably fast enough" and "provably correct."

This is one of 18 chapters

Every chapter is free — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

Sign up free