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).
niceranges -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,reniceare the user-facing controls.
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?
Why
Nice is inverted: smaller values mean higher priority/weight; it is a hint, not a guarantee.