Systems study
Offline — showing the cached copy.
Home / Operating Systems / 3. Scheduling

3. Scheduling

One-liner. Linux runs the task with the earliest virtual deadline, not the shortest job.

Memorize

  • CFS (through 6.5) tracked vruntime; since 6.6 the default is EEVDF (eligible tasks, earliest virtual deadline).
  • nice ranges -20 (most CPU) to 19 (least); each step is roughly a 10% weight change.
  • Real-time classes (SCHED_FIFO, SCHED_RR) preempt normal tasks; a busy RT task can starve the box.
  • Preemption: the scheduler can interrupt user code; kernel preemption depends on config (PREEMPT_*).
  • Load balancing moves tasks between CPUs; affinity pins them; NUMA locality matters for memory-heavy work.
  • Latency vs throughput: more context switches improve responsiveness and hurt cache locality.
  • chrt, taskset, nice, renice are the user-facing controls.
PICK NEXT TASK Runqueue eligible(vruntime/deadline) pick earliestdeadline context switch run untilpreempted
Pick next task

Trap. Setting SCHED_FIFO on a busy thread — it can starve every normal task, including your shell. Do this. Use RT only with a bounded work loop and a CPU affinity mask.

Check

What does a lower nice value (e.g. -10) mean for a process?