Operating Systems and Architecture
COS3721
Assignment 3 [Total marks 50]
Important note:
Please note that the questions are based on the exercises in the prescribed textbook but,
are not the necessary the same. So, if you do the exercises in the textbook, you will not
have the same answers and your work will not be given any mark.
Question 1- (based on 11.12 and 11.15, p.526) [25]
(Ex0 11.12, p.526): Suppose that a disk drive has 4000 cylinders, numbered 0 to 3,999. The
drive is currently serving a request at cylinder 1,150, and the previous request was at cylinder
1,805. The queue of pending requests, in FIFO order, is:
2,069; 1,212; 2,296; 2,800; 544; 1,618; 356; 1,523; 3,965; 3,681
Starting from the current head position, what is the total distance (in cylinders) that the disk arm
moves to satisfy all the pending requests for each of the following disk-scheduling algorithms?
a. FCFS (5)
b. SCAN (5)
c. C-SCAN (5)
~ calculate the distance traveled for each request and then sum up these distances to get the total
distance.
Given:
- Current position: 1,150
- Previous request position: 1,805
- Pending requests: 2,069; 1,212; 2,296; 2,800; 544; 1,618; 356; 1,523; 3,965; 3,681
- Total number of cylinders: 4,000
a. FCFS (First-Come, First-Served):
, In FCFS, the requests are served in the order they were received.
Total distance = Sum of absolute differences between consecutive request positions
1,150 -> 2,069 = 919
2,069 -> 1,212 = 857
1,212 -> 2,296 = 1,084
2,296 -> 2,800 = 504
2,800 -> 544 = 2,256
544 -> 1,618 = 1,074
1,618 -> 356 = 1,262
356 -> 1,523 = 1,167
1,523 -> 3,965 = 2,442
3,965 -> 3,681 = 284
Total distance = 919 + 857 + 1,084 + 504 + 2,256 + 1,074 + 1,262 + 1,167 + 2,442 + 284 = 12,909
b. SCAN (Elevator):
In SCAN, the arm moves in one direction (either towards the end or towards the beginning) until it
reaches the end of the disk, and then it reverses direction.
Total distance = Sum of distances within the current direction + Distance to the end + Distance to the
last request
1,150 -> 3,999 = 2,849 (towards the end)
3,999 -> 3,681 = 318 (reversing direction)
3,681 -> 356 = 3,325 (reversing direction)
356 -> 544 = 188 (reversing direction)
544 -> 1,212 = 668 (reversing direction)
Total distance = 2,849 + 318 + 3,325 + 188 + 668 = 7,348
COS3721
Assignment 3 [Total marks 50]
Important note:
Please note that the questions are based on the exercises in the prescribed textbook but,
are not the necessary the same. So, if you do the exercises in the textbook, you will not
have the same answers and your work will not be given any mark.
Question 1- (based on 11.12 and 11.15, p.526) [25]
(Ex0 11.12, p.526): Suppose that a disk drive has 4000 cylinders, numbered 0 to 3,999. The
drive is currently serving a request at cylinder 1,150, and the previous request was at cylinder
1,805. The queue of pending requests, in FIFO order, is:
2,069; 1,212; 2,296; 2,800; 544; 1,618; 356; 1,523; 3,965; 3,681
Starting from the current head position, what is the total distance (in cylinders) that the disk arm
moves to satisfy all the pending requests for each of the following disk-scheduling algorithms?
a. FCFS (5)
b. SCAN (5)
c. C-SCAN (5)
~ calculate the distance traveled for each request and then sum up these distances to get the total
distance.
Given:
- Current position: 1,150
- Previous request position: 1,805
- Pending requests: 2,069; 1,212; 2,296; 2,800; 544; 1,618; 356; 1,523; 3,965; 3,681
- Total number of cylinders: 4,000
a. FCFS (First-Come, First-Served):
, In FCFS, the requests are served in the order they were received.
Total distance = Sum of absolute differences between consecutive request positions
1,150 -> 2,069 = 919
2,069 -> 1,212 = 857
1,212 -> 2,296 = 1,084
2,296 -> 2,800 = 504
2,800 -> 544 = 2,256
544 -> 1,618 = 1,074
1,618 -> 356 = 1,262
356 -> 1,523 = 1,167
1,523 -> 3,965 = 2,442
3,965 -> 3,681 = 284
Total distance = 919 + 857 + 1,084 + 504 + 2,256 + 1,074 + 1,262 + 1,167 + 2,442 + 284 = 12,909
b. SCAN (Elevator):
In SCAN, the arm moves in one direction (either towards the end or towards the beginning) until it
reaches the end of the disk, and then it reverses direction.
Total distance = Sum of distances within the current direction + Distance to the end + Distance to the
last request
1,150 -> 3,999 = 2,849 (towards the end)
3,999 -> 3,681 = 318 (reversing direction)
3,681 -> 356 = 3,325 (reversing direction)
356 -> 544 = 188 (reversing direction)
544 -> 1,212 = 668 (reversing direction)
Total distance = 2,849 + 318 + 3,325 + 188 + 668 = 7,348