CSOS & ConcurrencyDiagramIntermediate
CPU Scheduling
KO: CPU 스케줄링·EN: CPU Scheduling·JA: CPUスケジューリング
The OS kernel policy deciding which ready process or thread runs on each CPU core next to balance throughput, latency, and fairness
Table of Contents
Structure Diagram
CPU Scheduling: Preemptive Round Robin Time-Slicing
CPU Timeline (Quantum=20ms)5 steps
STEP 1Task A(20ms)
Quick Answer
What is CPU Scheduling?
The OS kernel policy deciding which ready process or thread runs on each CPU core next to balance throughput, latency, and fairness. It is a core concept in OS & Concurrency within CS.
Core Principles
CPU Scheduling determines which runnable process or thread gets each CPU core next, balancing throughput, turnaround time, responsiveness, and fairness.
- Core Algorithms:
- FCFS / SJF: First-Come or Shortest-Job-First (prone to convoy effect or starvation).
- Round Robin: Gives every task an equal time quantum with preemption for predictable responsiveness.
- MLFQ & Linux CFS/EEVDF: Prioritizes interactive I/O-bound tasks while tracking virtual runtime to ensure fair CPU shares.
Practical Takeaways
- Time-quantum trade-off: Too small increases context-switching waste; too large degrades interactive tail latency.
- Kubernetes CFS Throttling: Tight
limits.cpucaps can cause multi-threaded pods to burn their 100ms quota early and stall until the next period, spiking P99 latency. - CPU Pinning (Affinity): Latency-critical services pin threads to dedicated cores to avoid cross-core cache migration.
Notable Examples
- Linux CFS & EEVDF: Red-Black Tree virtual-runtime scheduling in modern Linux kernels.
- Real-Time OS (RTOS): Earliest Deadline First (EDF) for robotics, avionics, and audio DSP.