Quiz 2

I/O Systems & Disk Scheduling

766 words
4 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# I/O Systems & Disk Scheduling ## 🎯 Learning Objectives - Explain the layered structure of the I/O system - Trace FCFS, SSTF, SCAN, C-SCAN, LOOK, and C-LOOK disk scheduling - Calculate seek time, rotational latency, and transfer time - Choose the right scheduling algorithm for different workloads * * * ## 1. I/O H...

I/O Systems & Disk Scheduling

🎯 Learning Objectives

  • Explain the layered structure of the I/O system
  • Trace FCFS, SSTF, SCAN, C-SCAN, LOOK, and C-LOOK disk scheduling
  • Calculate seek time, rotational latency, and transfer time
  • Choose the right scheduling algorithm for different workloads

1. I/O Hardware

1.1 I/O Hierarchy

(Diagram)

1.2 I/O Methods

MethodDescriptionCPU UsageData Path
Programmed I/O (PIO)CPU polls device, transfers each byteVery highCPU → Device
Interrupt-drivenCPU starts transfer, device interrupts on completionMediumCPU → Device
DMADMA controller handles transfer, interrupts CPU on completionLowDevice → Memory (no CPU)

2. Disk Structure

2.1 Disk Geometry

(Diagram)

2.2 Disk Access Time Components

Access Time=Seek Time+Rotational Latency+Transfer Time\text{Access Time} = \text{Seek Time} + \text{Rotational Latency} + \text{Transfer Time}
ComponentTypical ValueFormula
Seek time3-15 msMove arm to correct cylinder
Rotational latency2-8 ms (half rotation)1/(2 × RPM/60)
Transfer time0.01-1 mssectors × sector_size / transfer_rate
Example: 7200 RPM disk, 5ms seek, transfer 512 bytes at 100 MB/s.
  • Rotational latency = 60 / (7200 × 2) = 4.17 ms
  • Transfer time = 512 / (100 × 10^6) = 0.005 ms
  • Total ≈ 9.17 ms (seek dominates!)

3. Disk Scheduling Algorithms

3.1 Worked Example (Same Queue for All)

Request queue: 98, 183, 37, 122, 14, 124, 65, 67 Initial head position: 53 Direction: Towards 0 (left) or 199 (right)

3.2 FCFS (First Come, First Served)

Order: 53 → 98 → 183 → 37 → 122 → 14 → 124 → 65 → 67 Movement: |98-53| + |183-98| + |37-183| + |122-37| + |14-122| + |124-14| + |65-124| + |67-65| = 45 + 85 + 146 + 85 + 108 + 110 + 59 + 2 = 640 cylinders Gantt-style path:
pseudo
53 → 98 (45) → 183 (85) → 37 (146) → 122 (85) → 14 (108) → 124 (110) → 65 (59) → 67 (2)

3.3 SSTF (Shortest Seek Time First)

Always pick the request with the shortest seek distance from current position.
StepCurrentCandidates (distance)ChosenMovement
15337(16), 65(12), 67(14), 98(45), 122(69), 14(39)6512
26537(28), 67(2), 98(33), 122(57), 14(51)672
36737(30), 98(31), 122(55), 14(53)3730
43798(61), 122(85), 14(23)1423
51498(84), 122(108)9884
698122(24)12224
7122183(61)18361
8183Done
Total movement: 12 + 2 + 30 + 23 + 84 + 24 + 61 = 236 cylinders

3.4 SCAN (Elevator Algorithm)

Move in one direction, servicing all requests, then reverse direction. Direction: towards 199 (right)
StepCurrentDirectionServiceNextMovement
153
265656512
36767672
498989831
512212212224
618318318361
7199→ (end)16
8199
912412475
10373787
11141423
Total movement: (199-53) + (199-14) = 146 + 185 = 331 cylinders

3.5 C-SCAN (Circular SCAN)

Move in one direction servicing requests, then jump back to the start and repeat. Direction: towards 199 (right)
StepCurrentServiceMovement
153
2656512
367672
4989831
512212224
618318361
7199 (end)16
80 (jump)199
9141414
10373723
Total movement: (199-53) + (199-0) + (37-0) = 146 + 199 + 37 = 382 cylinders

3.6 LOOK and C-LOOK

Same as SCAN/C-SCAN but only go as far as the last request in each direction.
AlgorithmPathTotal Movement
LOOK53→65→67→98→122→183→124→37→14(183-53)+(183-14)=130+169=299
C-LOOK53→65→67→98→122→183→14→37(183-53)+(183-14)+(37-14)=130+169+23=322

3.7 Comparison

AlgorithmTotal MovementStarvation?Direction Bias?ProsCons
FCFS640NoNoSimple, fairVery slow
SSTF236YesNoLowest movementStarves far requests
SCAN331NoYes (middle better)No starvationEnd-to-end latency
C-SCAN382NoMore uniformUniform wait timesJump overhead
LOOK299NoYesAvoids full sweep
C-LOOK322NoNoMost balanced

4. 📐 Key Formulas / Concepts

ConceptFormula
Rotational latency1/(2 × RPM/60) seconds
Transfer timebytes / transfer_rate
Access timeseek + rotation + transfer
Disk throughputbytes / access_time

5. 📝 Practice Questions

Q1: Queue: 86, 147, 91, 177, 94, 150, 102, 130. Head at 100, direction right. Compute SCAN movement.
Answer: Order: 100→102(2)→130(28)→147(17)→150(3)→177(27)→199(22)→94(105)→91(3)→86(5) Movement = (199-100)+(199-86) = 99+113 = 212 Q2: Why does SSTF cause starvation?
Answer: SSTF always picks the shortest distance request. If new requests keep arriving close to the current position, far-away requests may never be serviced. This is analogous to shortest-job-first in CPU scheduling. Q3: A disk rotates at 15000 RPM. What is the average rotational latency?
Answer: Average rotational latency = 60/(15000×2) = 60/30000 = 2 ms. Q4: Compare SCAN and C-SCAN in terms of waiting time variance.
Answer: SCAN favors cylinders in the middle (get serviced on both passes). C-SCAN treats all cylinders more uniformly because the head always traverses in one direction, so the wait time depends on how far the cylinder is from the head's current pass direction. Q5: What prevents FCFS from being optimal for disk scheduling?
Answer: FCFS doesn't optimize for mechanical movement. It serves requests in arrival order, causing the disk arm to bounce back and forth across the disk surface. This maximizes seek time and provides the worst throughput.

6. 🔗 Cross-References

Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.