Operating Systems ยท Unit 6 ยท 6 hrs
Device Management
Exam-focused notes for Device Management (Operating Systems, CSC264): what the TU syllabus asks and how it has actually been tested, with 11 solved past questions from this unit.
Device Management in short
This chapter covers device management: how the operating system classifies and drives the input and output hardware attached to a computer, the mechanisms (programmed I/O, interrupts, DMA) used to move data between devices and memory, and the disk-specific scheduling and formatting techniques that keep the slowest common device performing well.
What this unit covers
- Classification of IO devices
- Controllers
- Memory Mapped IO
- DMA Operation
- Interrupts
- Goals of IO Software
- Handling IO(Programmed IO, Interrupt Driven IO, IO using DMA)
- IO Software Layers (Interrupt Handlers, Device Drivers)
- Disk Structure
- Disk Scheduling (FCFS, SSTF, SCAN, CSCAN, LOOK, CLOOK)
- Disk Formatting (Cylinder Skew, Interleaving, Error handling)
- RAID
Disk Scheduling
2081 ยท 10 marks
Find the seek time using SCAN, C-SCAN, Look and C-Look disk scheduling algorithms for processing the following request queue: 35, 70, 45, 15, 65, 20, 80, 90, 75, 130. Suppose the disk has tracks numbered from 0 to 150 and assume the disk arm to be at 30 and moving outward.[10]
Show solved answerHide answer
Disk Scheduling Algorithms - Verified Solution
Given Data
- Request Queue: 35, 70, 45, 15, 65, 20, 80, 90, 75, 130
- Track range: 0 to 150
- Initial head position: 30
- Direction: Outward (toward higher tracks)
Sorted requests: 15, 20, 35, 45, 65, 70, 75, 80, 90, 130
1. SCAN
Head moves outward to 150, then reverses to service lower requests.
Order: 30 โ 35 โ 45 โ 65 โ 70 โ 75 โ 80 โ 90 โ 130 โ 150 โ 20 โ 15
Total distance = (150 โ 30) + (150 โ 15) = 120 + 135 = 255 tracks
2. C-SCAN
Head moves outward to 150, jumps to 0, then continues servicing.
Order: 30 โ 35 โ ... โ 130 โ 150 โ 0 โ 15 โ 20
Total = (150 โ 30) + (150 โ 0) + (20 โ 0) = 120 + 150 + 20 = 290 tracks
(Equivalently, summing the individual steps: 5+10+20+5+5+5+10+40+20+150+15+5 = 290.)
3. LOOK
Head moves outward only to the last request (130), then reverses.
Order: 30 โ 35 โ ... โ 130 โ 20 โ 15
Total = (130 โ 30) + (130 โ 15) = 100 + 115 = 215 tracks
4. C-LOOK
Head moves outward to last request (130), jumps to lowest request (15), continues outward.
Order: 30 โ 35 โ ... โ 130 โ 15 โ 20
| Movement | From | To | Distance |
|---|---|---|---|
| 1 | 30 | 35 | 5 |
| 2 | 35 | 45 | 10 |
| 3 | 45 | 65 | 20 |
| 4 | 65 | 70 | 5 |
| 5 | 70 | 75 | 5 |
| 6 | 75 | 80 | 5 |
| 7 | 80 | 90 | 10 |
| 8 | 90 | 130 | 40 |
| 9 | 130 | 15 | 115 |
| 10 | 15 | 20 | 5 |
Total = (130 โ 30) + (130 โ 15) + (20 โ 15) = 100 + 115 + 5 = 220 tracks
Summary
| Algorithm | Seek Time (tracks) |
|---|---|
| SCAN | 255 |
| C-SCAN | 290 |
| LOOK | 215 |
| C-LOOK | 220 |
2080 ยท 5 marks
Suppose a disk has 201 cylinders, numbered from 0 to 200. At same time the disk arm is at cylinder 10, and there is a queue of disk access requests for cylinders 30, 85, 90, 100, 105, 110, 135, and 145. Find the total seek time for the disk scheduling algorithm FCFS and SSTF. Assume the head is moving inward. [5]
2079 ยท 10 marks
Define shell and system call. Suppose a disk has 201 cylinders, numbered from 0 to 200. At same time the disk arm is at cylinder 95, and there is a queue of disk access requests for cylinders 82,170,43,140,24,16 and 190. Calculate the seek time for the disk scheduling algorithm FCFS,SSTF,SCAN and C-SCAN.[10]
Show solved answerHide answer
Shell, System Call, and Disk Scheduling
Part 1: Definitions
Shell
A shell is a command interpreter that provides the interface between the user and the operating system kernel. It accepts user commands, interprets them, and hands them to the OS for execution. It also lets users run programs, manage files, and control processes. Examples: Bash, sh, csh, zsh.
System Call
A system call is the programmatic interface through which a user process requests a service from the OS kernel. It transfers control from user mode to kernel mode for privileged operations. Examples: fork(), exec(), read(), write(), open().
Part 2: Disk Scheduling
Given data:
- Cylinders: 201 (numbered 0 to 200)
- Head start: 95
- Queue (arrival order): 82, 170, 43, 140, 24, 16, 190
1. FCFS
Order: $95 \to 82 \to 170 \to 43 \to 140 \to 24 \to 16 \to 190$
$$|95-82|+|82-170|+|170-43|+|43-140|+|140-24|+|24-16|+|16-190|$$ $$= 13+88+127+97+116+8+174 = \boxed{623}$$
2. SSTF
| Step | Pos | Closest | Dist |
|---|---|---|---|
| 1 | 95 | 82 | 13 |
| 2 | 82 | 43 | 39 |
| 3 | 43 | 24 | 19 |
| 4 | 24 | 16 | 8 |
| 5 | 16 | 140 | 124 |
| 6 | 140 | 170 | 30 |
| 7 | 170 | 190 | 20 |
Order: $95 \to 82 \to 43 \to 24 \to 16 \to 140 \to 170 \to 190$
$$13+39+19+8+124+30+20 = \boxed{253}$$
3. SCAN (moving up toward 200)
Sorted: $16, 24, 43, 82, [95], 140, 170, 190$
Order: $95 \to 140 \to 170 \to 190 \to 200 \to 82 \to 43 \to 24 \to 16$
$$45+30+20+10+118+39+19+8 = \boxed{289}$$
Total = $(200-95) + (200-16) = 105 + 184 = 289$ โ
4. C-SCAN (moving up toward 200, then wrap to 0)
Order: $95 \to 140 \to 170 \to 190 \to 200 \to 0 \to 16 \to 24 \to 43 \to 82$
| From | To | Dist |
|---|---|---|
| 95 | 140 | 45 |
| 140 | 170 | 30 |
| 170 | 190 | 20 |
| 190 | 200 | 10 |
| 200 | 0 | 200 |
| 0 | 16 | 16 |
| 16 | 24 | 8 |
| 24 | 43 | 19 |
| 43 | 82 | 39 |
$$45+30+20+10+200+16+8+19+39 = \boxed{387}$$
Summary
| Algorithm | Total Seek (cylinders) |
|---|---|
| FCFS | 623 |
| SSTF | 253 |
| SCAN | 289 |
| C-SCAN | 387 |
2076 ยท 10 marks
What is the main objective of disk scheduling algorithms? Why SSTF is not practically feasible? Assume that we have disk with 100 tracks and currently head is at track number 35. What will be the seek time for the algorithms SCAN and LOOK for processing IO requests queue: 52, 67, 21, 11, 43, 85, 18, 75, 92, 8?[10]
Show solved answerHide answer
Disk Scheduling: Objectives, SSTF Feasibility, SCAN and LOOK
1. Main Objective of Disk Scheduling Algorithms
The primary objective of disk scheduling is to minimize the total seek time (the time the disk arm spends moving between tracks), because seek time dominates disk access latency and the disk is one of the slowest components of a system.
Related objectives:
- Maximize throughput (requests served per unit time)
- Minimize disk arm movement by ordering requests intelligently
- Ensure fairness so no request starves
- Minimize average response and waiting time
2. Why SSTF Is Not Practically Feasible
SSTF (Shortest Seek Time First) always services the request nearest to the current head position.
- Starvation: Requests far from the head may wait indefinitely if closer requests keep arriving. This is the main reason it is not practically feasible.
- Unfairness: Requests to the innermost/outermost tracks are consistently delayed.
- Not globally optimal: Minimizing each local step does not minimize total head movement.
- Unpredictable response time: Hard to guarantee bounded waiting.
Because of starvation and unfairness, SSTF is attractive theoretically but unsuitable in practice.
3. Numerical Solution
Given data:
- Total tracks: 100 (tracks $0$ to $99$)
- Current head position: 35
- Request queue: 52, 67, 21, 11, 43, 85, 18, 75, 92, 8
- Assumed initial direction: toward higher track numbers (standard assumption)
Sorted requests: 8, 11, 18, 21, 43, 52, 67, 75, 85, 92
SCAN (Elevator)
Head moves up, servicing all requests, reaches end track 99, then reverses to service lower requests.
Order: $35 \to 43 \to 52 \to 67 \to 75 \to 85 \to 92 \to 99 \to 21 \to 18 \to 11 \to 8$
| From | To | Distance |
|---|---|---|
| 35 | 43 | 8 |
| 43 | 52 | 9 |
| 52 | 67 | 15 |
| 67 | 75 | 8 |
| 75 | 85 | 10 |
| 85 | 92 | 7 |
| 92 | 99 | 7 |
| 99 | 21 | 78 |
| 21 | 18 | 3 |
| 18 | 11 | 7 |
| 11 | 8 | 3 |
Alternatively, total movement = (up: $99-35=64$) + (down: $99-8=91$) = $155$.
$$\text{Total Seek (SCAN)} = 8+9+15+8+10+7+7+78+3+7+3 = \mathbf{155 \text{ tracks}}$$
LOOK
Same as SCAN but the head only goes as far as the last request (92) in the upward direction, not to track 99.
Order: $35 \to 43 \to 52 \to 67 \to 75 \to 85 \to 92 \to 21 \to 18 \to 11 \to 8$
| From | To | Distance |
|---|---|---|
| 35 | 43 | 8 |
| 43 | 52 | 9 |
| 52 | 67 | 15 |
| 67 | 75 | 8 |
| 75 | 85 | 10 |
| 85 | 92 | 7 |
| 92 | 21 | 71 |
| 21 | 18 | 3 |
| 18 | 11 | 7 |
| 11 | 8 | 3 |
Alternatively, total movement = (up: $92-35=57$) + (down: $92-8=84$) = $141$.
$$\text{Total Seek (LOOK)} = 8+9+15+8+10+7+71+3+7+3 = \mathbf{141 \text{ tracks}}$$
Summary
| Algorithm | Total Seek Time |
|---|---|
| SCAN | 155 tracks |
| LOOK | 141 tracks |
(If seek time per track is $t$ ms, multiply by $t$: SCAN $=155t$, LOOK $=141t$.)
Memory Mapped IO
Interrupts
2080 ยท 5 marks
What are the advantages of using interrupt? Describe. [5]
DMA Operation
2080.1 ยท 10 marks
How DMA operation is performed? Consider a disk with 200 tracks and the queue has random requests from different processes in the order: 45, 48, 29, 17, 80, 150, 28 and 188. Find the seek time using FIFO, SSTF and SCAN. Assume the initial position of head as 100.[10]
Controllers
2079 ยท 5 marks
What is the task of disk controller? List some drawback of segmentation. [5]
Disk Formatting
2078 ยท 5 marks
Why the concept of disk interleaving is important? Explain with suitable example. [5]
Handling IO
2076 ยท 5 marks
When programmed IO is suitable than other IO handling techniques? Explain the process of IO handling using DMA. [5]
Make Unit 6 stick
Practice CSC264 with flashcards & quizzes