CPU Scheduling Criteria
BeginnerCPU scheduling algorithms are evaluated on five criteria: CPU utilization, throughput, turnaround time, waiting time, and response time — each optimization target suiting different system types.
Overview
The OS scheduler must decide which process runs next. To compare scheduling algorithms, five performance metrics are used. CPU Utilization: keep the CPU as busy as possible (target: 40%–90%). Throughput: number of processes completed per unit time. Turnaround Time: total time from process submission to completion (includes waiting + execution + I/O). Waiting Time: total time a process spends in the ready queue. Response Time: time from submission to the first CPU response — critical for interactive systems. Batch systems optimize throughput; interactive systems optimize response time; real-time systems optimize worst-case latency. Understanding these criteria lets you explain why different algorithms suit different workloads.
The Five Scheduling Metrics
Think of processes as customers at a bank. CPU Utilization = how busy the teller is. Throughput = customers served per hour. Turnaround Time = total time from entering the bank to leaving. Waiting Time = time spent sitting in the queue. Response Time = time until the teller first acknowledges you. For online banking (interactive), response time matters most. For batch statement generation, throughput matters most.
// Calculating scheduling metrics for 3 processes (non-preemptive)
// Process | Arrival | Burst
// P1 | 0 | 6
// P2 | 2 | 3
// P3 | 4 | 1
// FCFS order: P1, P2, P3
// Gantt chart:
// | P1 (0-6) | P2 (6-9) | P3 (9-10) |
// 0 6 9 10
int[] arrival = {0, 2, 4};
int[] burst = {6, 3, 1};
int[] start = {0, 6, 9}; // when each process first gets CPU
int[] finish = {6, 9, 10}; // when each process completes
int n = 3;
double totalTurnaround = 0, totalWait = 0;
for (int i = 0; i < n; i++) {
int turnaround = finish[i] - arrival[i]; // finish - arrival
int waiting = turnaround - burst[i]; // turnaround - burst
System.out.printf("P%d → Turnaround: %d, Waiting: %d%n",
i + 1, turnaround, waiting);
totalTurnaround += turnaround;
totalWait += waiting;
}
System.out.printf("Avg Turnaround: %.1f%n", totalTurnaround / n);
System.out.printf("Avg Waiting: %.1f%n", totalWait / n);
// Avg Turnaround: 5.67 Avg Waiting: 2.67Optimization Goals by System Type
Different system types prioritize different metrics. Batch systems (scientific computing, payroll) maximize throughput and CPU utilization. Interactive systems (desktops, web apps) minimize response time and waiting time. Real-time systems (airbag controllers, medical devices) must meet hard deadlines — worst-case latency is the metric. Embedded systems balance all metrics under strict power constraints.
// Demonstrating response time importance in interactive systems
// Response time = time from request to first byte of response
// BAD: one long task blocks all short tasks (poor response time)
// | LONG_TASK (0–100ms) | SHORT1 (100–101ms) | SHORT2 (101–102ms) |
// Response time for SHORT1 = 100ms — user notices lag
// GOOD: Round Robin gives every task CPU time quickly
// | LONG(0-10) | SHORT1(10-11) | SHORT2(11-12) | LONG(12-22) | ...
// Response time for SHORT1 = 10ms — snappy
// Java: measuring task response time with CompletableFuture
long submitTime = System.nanoTime();
CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> {
// simulate work
return "result";
});
future.thenAccept(result -> {
long responseTime = System.nanoTime() - submitTime;
System.out.printf("Response time: %.2f ms%n", responseTime / 1e6);
});Key Points to Remember
- 1CPU Utilization: percentage of time CPU is busy; target 40–90% in practice.
- 2Throughput: processes completed per unit time; optimize for batch workloads.
- 3Turnaround Time = finish time - arrival time; includes waiting + execution + I/O.
- 4Waiting Time = turnaround time - burst time; time spent only in the ready queue.
- 5Response Time = time from submission to first response; critical for interactive systems.
- 6No single algorithm optimizes all metrics — trade-offs depend on the system type.
Interview Questions
Sign in to ask AriaWhat is the difference between turnaround time and waiting time?
Which scheduling metric matters most for an interactive user-facing application?
If CPU utilization is 100%, is that always desirable? Why or why not?
Calculate average waiting and turnaround time for 3 processes with FCFS given arrival and burst times.
Ask Aria about CPU Scheduling Criteria
Your personal AI tutor — ask anything about this concept
Revision Status
Personal Notes
Sign in to save personal notes for this topic.
Discussion
Sign in to join the discussion.