Professional Documents
Culture Documents
Assignment#4: Name: Roll No: Subject: Class: Section
Assignment#4: Name: Roll No: Subject: Class: Section
Class: BSCS
Section: 5A
Ans:
FCFS
|50-176|+|176-79|+|79-34|+|34-60|+|60-92|+|92-11|+|11-41|+|41-114|+|114-90|+|90-30|+|30-
14|+|14-20|+|20-80|+|80-66|
=|126|+|97|+|45|+|26|+|32|+|81|+|30|+|73|+|24|+|60|+|16|+|6|+|60|+|14|
FCFS=690
= 204
Implementation –
Implementation of SSTF is given below. Note that we have made a node class having 2 members.
‘distance’ is used to store the distance between head and the track position. ‘accessed’ is a Boolean
variable which tells whether the track has been accessed/serviced before by disk head or not.
.
Q#2
Suppose that a disk drive has 5,000 cylinders, numbered 0 to 4,999. The drive is currently
serving a request at cylinder 2,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, 4,965, 3681.
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
b. SSTF
0 356 544 1212 1523 1618 2069 2150(head) 2296 2800 3681 4965 4999
0 356 544 1212 1523 1618 2069 2150 (head) 2296 2800 3681 4965 4999
SEEK TIME:
2,069, 1,212, 2,296, 2,800, 544, 1,618, 356, 1,523, 4,965, 3681.
|2150-2069| + |2069-1212| + |1212-2296| + |2296-2800| + |2800-544| + |544-1618| + |1618-356|
+ |356-1523| + |1523-4965| + |4965-3681|
81+857+1084+504+2256+1074+1262+1167+3442+1284
13011 tracks
0 356 544 1212 1523 1618 2069 2150 (head) 2296 2800 3681 4965 4999
SEEK TIME:
2,069, 1,212, 2,296, 2,800, 544, 1,618, 356, 1,523, 4,965, 3681.
|2150-2069| + |2069-2296| + |2296-2800| + |2800-1618| + |1618-1523| + |1523-1212| + |1212-
544| + |544-356| + |356-3681| + |3681-4965|
81+227+504+1182+95+311+668+188+3325+1284
7865 tracks