You are on page 1of 4

ASSIGNMENT#4

Name: Arbaz Ahmad Khan

Roll No: BCSM-F18-308

Subject: Operating System

Class: BSCS

Section: 5A

Submitted To: Miss Arshia


Q#1
Apply SSTF & FCFS Scheduling Algorithms and Request sequence = {176, 79, 34, 60, 92, 11,
41, 114,90 ,30 ,14 ,20 ,80 ,66}
Initial head position = 50. Find out the seek operational result.

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

Shortest Seek Time First (SSTF)


Totals seek count is calculates as:

= (50-41) +(41-34) +(34-11) +(60-11) +(79-60)+(92-79)+(114-92)+(176-114)

= 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

First come First server:


2,069, 1,212, 2,296, 2,800, 544, 1,618, 356, 1,523, 4,965, 3681.

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

Shortest seek time first:


2,069, 1,212, 2,296, 2,800, 544, 1,618, 356, 1,523, 4,965, 3681.

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

You might also like