Under nonpreemptive scheduling, the CPU is taken from a process only when it:
CPU Scheduling
CPU–I/O burst cycle, preemptive vs. nonpreemptive scheduling, the dispatcher, scheduling criteria, FCFS, SJF and SRTF (with exponential averaging), Round Robin, priority, multilevel and multilevel feedback queues, thread and real-time scheduling, and algorithm evaluation.
How to read this page
Every original slide is shown unchanged. Yellow marks on a slide point to a numbered note: hover or tap a mark to jump to its note, and hover a note to see its marks. Questions tagged Past exam appeared on a real paper; Prediction questions are likely angles, not confirmed. Pick an answer to each question: a wrong pick tells you why it is wrong, so you can try again.
All 45 slides
- 1 Slide 1
- 2 Outline
- 3 Objectives
- 4 Basic Concepts
- 5 Histogram of CPU-burst Times
- 6 CPU Scheduler
- 7 Preemptive and Nonpreemptive Scheduling
- 8 Preemptive Scheduling and Race Conditions
- 9 Dispatcher
- 10 Scheduling Criteria
- 11 Scheduling Algorithm Optimization Criteria
- 12 First- Come, First-Served (FCFS) Scheduling
- 13 FCFS Scheduling (Cont.)
- 14 Shortest-Job-First (SJF) Scheduling
- 15 Example of SJF
- 16 Determining Length of Next CPU Burst
- 17 Prediction of the Length of the Next CPU Burst
- 18 Examples of Exponential Averaging
- 19 Shortest Remaining Time First Scheduling
- 20 Example of Shortest-remaining-time-first
- 21 Round Robin (RR)
- 22 Example of RR with Time Quantum = 4
- 23 Time Quantum and Context Switch Time
- 24 Turnaround Time Varies With The Time Quantum
- 25 Priority Scheduling
- 26 Example of Priority Scheduling
- 27 Priority Scheduling w/ Round-Robin
- 28 Multilevel Queue
- 29 Multilevel Queue
- 30 Multilevel Queue
- 31 Multilevel Feedback Queue
- 32 Example of Multilevel Feedback Queue
- 33 Thread Scheduling
- 34 Dispatch Latency
- 35 Priority-based Scheduling
- 36 Rate Monotonic Scheduling
- 37 Operating System Examples
- 38 Windows Priorities
- 39 Solaris
- 40 Solaris Scheduling
- 41 Solaris Scheduling (Cont.)
- 42 Algorithm Evaluation
- 43 Deterministic Evaluation
- 44 Queueing Models
- 45 Slide 45
Preemptive and Nonpreemptive Scheduling
Notes
Scheduling decisions when a process: 1) running → waiting, 2) running → ready, 3) waiting → ready, 4) terminates. Only 1 and 4 → nonpreemptive; otherwise preemptive.
Exam angle
Dispatcher
Notes
Dispatcher gives the CPU to the chosen process: context switch, switch to user mode, jump to the right instruction. Dispatch latency = time to do this.
Scheduling Criteria
Notes
Tip Waiting time = turnaround − burst. Turnaround = completion − arrival. Response = first run − arrival. Draw the Gantt chart first.
Exam angle
Which criterion should be MINIMIZED?
First- Come, First-Served (FCFS) Scheduling
Notes
FCFS: run in arrival order; nonpreemptive. Convoy effect: short processes wait behind a long one.
Exam angle
P1 = 24, P2 = 3, P3 = 3 arrive in that order at time 0. FCFS average waiting time:
- (0 + 24 + 27) / 3.
FCFS Scheduling (Cont.)
Notes
Order P2, P3, P1 gives average wait (6 + 0 + 3) / 3 = 3: order matters a lot.
Shortest-Job-First (SJF) Scheduling
Notes
SJF: run the shortest next CPU burst. Optimal: minimum average waiting time for a given set. Problem: you can’t know the next burst length.
Exam angle
SJF gives the minimum average waiting time for a given set of processes.
Determining Length of Next CPU Burst
Exam angle
τ₀ = 10, α = 0.5, the actual burst t₀ = 6. τ₁ =
- 0.5·6 + 0.5·10.
Shortest Remaining Time First Scheduling
Notes
SRTF = preemptive SJF: a new arrival with a shorter burst than the remaining time preempts the running process.
Trap In SRTF compare the newcomer with the REMAINING time of the running process, not its original burst.
Round Robin (RR)
Exam angle
P1 = 24, P2 = 3, P3 = 3, RR with q = 4. P1 completes at time:
- P1 runs 0–4, P2 4–7, P3 7–10, then P1 alone until 30.
Time Quantum and Context Switch Time
Notes
Large q → behaves like FCFS. Small q → too many context switches. q should be large compared with the context-switch time (80% of bursts < q).
Exam angle
If the RR time quantum is very large, RR behaves like:
Priority Scheduling
Notes
Priority scheduling (smaller number = higher priority here). Problem: starvation. Solution: aging (raise priority over time).
Exam angle
The solution to starvation in priority scheduling is:
Multilevel Queue
Notes
Multilevel queue: separate queues (e.g. foreground RR, background FCFS), each with its own algorithm; scheduling between queues by fixed priority or time slices.
Multilevel Feedback Queue
Notes
Multilevel feedback queue: processes MOVE between queues (demote CPU-hogs, age old ones up).
Exam angle
What distinguishes a multilevel FEEDBACK queue from a multilevel queue?
Deterministic Evaluation
Notes
Deterministic modelling: compute each algorithm’s numbers for a given workload.