Operating Systems Level 5
PART 2 • RESOURCE CONTROL

Give Every Ready Process a Fair Turn on the CPU

Move beyond memorising algorithm names. Build schedules, inspect every decision, calculate each metric and explain which policy fits an interactive, batch or priority-sensitive workload.

Level 05 of 15 Intermediate 100–130 minutes Interactive simulator
BY THE END, YOU CAN

Build and defend a schedule

  • Separate scheduler policy from dispatcher mechanism.
  • Calculate CT, TAT, WT and RT correctly.
  • Trace preemptive and non-preemptive algorithms.
  • Explain convoy effect, starvation, aging and quantum trade-offs.
  • Select a policy using workload goals.
01 • SPEAK THE SCHEDULER'S LANGUAGE

Policy Chooses; the Dispatcher Performs the Switch

When several processes are ready, the short-term scheduler selects one. The dispatcher transfers control by switching context, entering user mode and jumping to the selected instruction.

1

Ready queue

Runnable processes wait for CPU service.

2

Scheduler

A policy selects the next process.

3

Dispatcher

Context is switched and control transferred.

4

Running

The process executes until an event or decision point.

NON-PREEMPTIVE

Keep the CPU until release

The running process continues until it terminates or blocks. Decisions are simpler, but a long burst can delay urgent short work.

PREEMPTIVE

The OS may take the CPU back

A timer, new arrival or priority change may trigger a new choice. Responsiveness improves, with extra context-switch and coordination cost.

02 • MEASURE THE RESULT

One Schedule Can Be Good by One Metric and Poor by Another

CT

Completion time

Clock time when the process finishes.

CT = finish time
TAT

Turnaround time

Total time from arrival to completion.

TAT = CT − AT
WT

Waiting time

Time spent ready but not executing.

WT = TAT − BT
RT

Response time

Delay until the process first gets CPU.

RT = first start − AT
CPU utilisation keep useful work running Throughput finish more jobs Turnaround finish jobs sooner Response react quickly Fairness prevent indefinite delay
03 • COMPARE THE POLICIES

Every Algorithm Encodes a Different Promise

FCFS

Arrival order

Non-preemptive and simple. A long job at the front creates the convoy effect.

Risk: poor response for short arrivals
SJF

Shortest next burst

Non-preemptive. Minimises average waiting for known bursts, but estimates can be wrong.

Risk: long-job starvation
SRTF

Shortest remaining work

Preemptive SJF. A newly arrived shorter job can replace the current one.

Risk: switching and starvation
PRIORITY

Importance first

Run the best priority value; this lesson uses a smaller number as higher priority.

Fix starvation with aging
ROUND ROBIN

Bounded time slices

Rotate the ready queue after one quantum. It favours responsiveness and sharing.

Quantum controls the trade-off
04 • INTERACTIVE GANTT LAB

Change the Workload and Recalculate Everything

Select a preset or edit the process table. The simulator builds the actual execution timeline, including idle spans and preemptions.

Process Arrival (AT) Burst (BT) Priority
FCFS

First Come, First Served

P1 P2 P3 P4 Idle
Process AT BT First CPU CT TAT WT RT

05 • MATCH POLICY TO PURPOSE

Diagnose the Workload before Naming an Algorithm

Choose the most important goal. The explanation highlights a sensible starting policy and the trade-off you must still defend.

06 • CALCULATE WITHOUT GUESSING

A Reliable Exam Method

1

Draw arrivals

Do not schedule a process before its arrival time.

2

Apply one decision rule

Resolve ties consistently, usually by arrival then process order.

3

Record first and final times

Preemptive jobs may have many spans but only one first start and completion.

4

Calculate in dependency order

Find CT, then TAT, then WT; find RT from first start.

Solved FCFS example

For P1(AT 0, BT 4), P2(AT 1, BT 3), P3(AT 2, BT 1), FCFS gives P1: 0–4, P2: 4–7, P3: 7–8. Completion times are 4, 7 and 8. Turnaround times are 4, 6 and 6. Waiting times are 0, 3 and 5. Because FCFS is non-preemptive, each response time equals its waiting time.

Solved Round Robin insight

With all jobs ready and quantum 2, each unfinished process receives at most two time units before moving behind other ready processes. A smaller quantum can improve early response, but too small a quantum spends excessive time switching rather than doing useful work.

07 • CHECK YOUR UNDERSTANDING

Ten Misconception-Specific Checks

Each option explains the exact reasoning behind it.

Answered correctly: 0 of 10
08 • EXPLAIN & PREPARE

University and Placement Questions

2-MARK QUESTIONS
  1. Define CPU scheduling.
  2. What is response time?
  3. Define preemption.
  4. What is the convoy effect?
  5. What is aging?
5-MARK QUESTIONS
  1. Compare FCFS and Round Robin.
  2. Calculate SJF metrics for four jobs.
  3. Explain SRTF with a Gantt chart.
  4. Discuss priority starvation and aging.
  5. Explain quantum selection.
INTERVIEW QUESTIONS
  1. Why is SJF theoretically attractive but difficult?
  2. Can waiting time exceed turnaround time?
  3. When does RR behave like FCFS?
  4. Does preemption always improve performance?
  5. How would you schedule interactive and batch work together?
Show a strong answer: “Compare FCFS and Round Robin”
  1. Classify FCFS as non-preemptive and RR as preemptive.
  2. Explain queue order and the RR quantum.
  3. Compare responsiveness, overhead and fairness.
  4. Mention FCFS convoy effect and RR quantum sensitivity.
  5. Conclude: FCFS suits simplicity; RR better supports time-sharing.
LEVEL 5 SUMMARY

You Can Now Turn a Ready Queue into a Defensible Schedule

  • Scheduling policy selects; dispatching performs the transfer.
  • CT leads to TAT and WT, while RT uses the first start.
  • FCFS is simple, shortest-job policies optimise short work, priority represents importance and RR shares time.
  • Preemption can improve response but adds switching cost.
  • Fairness mechanisms such as aging prevent indefinite postponement.
COURSE CHECKPOINT

Mark Level 5 after you can build one preemptive timeline and reproduce every metric from it.

Saved only in this browser.