CPU Scheduling: From FCFS to Linux CFS (The Art of Fairness)
CPU 스케줄링: 운영체제는 어떻게 공평함을 연기하는가? (FCFS부터 Linux CFS까지)
How OS creates the illusion of multitasking. Preemptive vs Non-preemptive, The Starvation problem, and how modern OSs use Multi-Level Feedback Queue (MLFQ) and Red-Black Trees (Linux CFS) to keep everyone happy.
c
codemapo
INTERDISCIPLINARY DEV · SEOUL
9. FAQ & Common Questions
Q: Is thread scheduling different from process scheduling?
A: In Linux, threads are treated as Light Weight Processes (LWP) and scheduled identically to processes. However, switching between threads of the same process is cheaper because they share memory regions (code, data, heap) — only stack and register state need to be saved.
Q: Why is frequent context switching bad?
A: Two reasons: (1) Register save/restore cost, and (2) Cache pollution — when a new process starts, it evicts the previous process's data from L1/L2 caches, causing a spike in cache misses. The TLB (Translation Lookaside Buffer) also gets flushed, slowing virtual memory address translation.
Q: How does multitasking work on a single core?
A: Time slicing. The OS switches processes every ~10ms. At 100 switches per second, human eyes perceive it as simultaneous execution — an optical illusion applied to computing.
Q: What's the difference between I/O bound and CPU bound?
A: I/O bound processes spend most of their time waiting (web browser waiting for network). CPU bound processes spend most of their time computing (rendering). Good schedulers give I/O bound processes higher priority because they quickly release the CPU after a short burst, improving overall system responsiveness.