Compare common CPU scheduling algorithms.
Assesses fundamental understanding of Operating Systems conventions, runtime behavior, and memory/performance considerations.
Hiring managers look for precision, avoidance of ambiguous jargon, and ability to explain trade-offs under real production conditions.
CPU scheduling decides which runnable thread runs next. Common policies:
- First Come First Served: simple and non-preemptive, but suffers the convoy effect when a long job blocks short ones.
- Shortest Job First: optimal average waiting time if burst lengths are known, but starvation is possible and bursts are usually guessed.
- Round Robin: each thread gets a time quantum; good response time, and the quantum trades context-switch overhead against interactivity.
- Priority: the highest priority runs; ageing prevents starvation.
- Multilevel feedback queue: multiple queues with different quanta, promoting interactive jobs and demoting CPU-bound ones.
RR with q=4: A(10) B(3) -> A4 B3 A4 A2
Real schedulers such as Linux's CFS approximate fair sharing by tracking virtual runtime rather than fixed priorities, and modern kernels also care about cache locality and NUMA. The right choice depends on whether the goal is throughput, latency or fairness.
Candidate Response Strategy & Interview Tips
- Start with a concise one-sentence summary: Deliver a direct, confident answer first before expanding into nuances.
- Demonstrate real-world trade-offs: Discuss where this approach excels and when you would avoid it in production systems.
- Discuss complexity & edge cases: Proactively explain time/space complexity or boundary conditions (null values, scale limits).
- Prepare for interviewer follow-ups: Technical hiring panels frequently probe deeper into concurrency, backward compatibility, or alternative libraries.