What is CPU scheduling?
Why Interviewers Ask This
This is a classic screening question for Operating Systems roles. Hiring managers ask it early in interviews to gauge your baseline understanding and determine if you can communicate technical concepts clearly.
Answer
CPU scheduling is the process of determining which ready process or thread should run on the CPU next. Since CPU is a scarce resource and multiple processes may be ready simultaneously, the OS scheduler decides which gets the CPU and for how long. Scheduling objectives: maximize CPU utilization (keep CPU busy), maximize throughput (jobs completed per unit time), minimize turnaround time (time from submission to completion), minimize waiting time (time in ready queue), minimize response time (time from request to first response), fairness. Types of scheduling: Non-preemptive (cooperative): once a process has the CPU, it keeps it until it finishes or blocks (I/O). Simple but poor for interactive systems. Preemptive: scheduler can interrupt a running process and give CPU to another. Most modern OSes use this. Required for fair sharing and real-time constraints. When scheduling decisions occur: process switches from running to waiting (always); process terminates (always); process switches from running to ready (preemptive); new process enters ready queue (preemptive). Scheduling algorithms: FCFS (First Come First Served), SJF (Shortest Job First), Priority Scheduling, Round Robin, Multilevel Queue, CFS (Completely Fair Scheduler — Linux default). Dispatcher: the module that gives CPU control to the selected process — involves context switching, switching to user mode, jumping to correct location in program. Dispatch latency = time to stop one process and start another.
Common Mistake
A common mistake is memorizing definitions without understanding implications. When asked this question, go one level deeper — explain what happens when this concept is misused or ignored.