Professional Documents
Culture Documents
Experiment:2.2: Aim: Tools/Software Required: Description
Experiment:2.2: Aim: Tools/Software Required: Description
Experiment:2.2
One of the responsibilities of the operating system is to use the hardware efficiently. For the
disk drives, meeting this responsibility entails having fast access time and large disk
bandwidth. Both the access time and the bandwidth can be improved by managing the order
in which disk I/O requests are serviced which is called as disk scheduling. The simplest form of
disk scheduling is, of course, the first-come, first-served (FCFS) algorithm. This algorithm is
intrinsically fair, but it generally does not provide the fastest service. In the SCAN algorithm, the
disk arm starts at one end, and moves towards the other end, servicing requests as it
reaches each cylinder, until it gets to the other end of the disk. At the other end, the direction of
head movement is reversed, and servicing continues. The head continuously scans back and
forth across the disk. C-SCAN is a variant of SCAN designed to provide a more uniform wait
time. Like SCAN, C-SCAN moves the head from one end of the disk to the other, servicing
requests along the way. When the head reaches the other end, however, it immediately
returns to the beginning of the disk without servicing any requests on the return trip.
FCFS is the simplest disk scheduling algorithm as the name suggests, this algorithm entertains
requests in the order they arrive in the disk queue. The algorithm looks very fair and there is no
starvation (all requests are serviced sequentially) but generally, it does not provide the
fastest service
In SCAN disk scheduling algorithm, head starts from one end of the disk and moves towards
the other end, servicing requests in between one by one and reach the other end. Then the
direction of the head is reversed and the process continues as head continuously scan back
and forth to access the disk. So, this algorithm works as an elevator and hence also known
as the elevator algorithm. As a result, the requests at the midrange are serviced more and
those arriving behind the disk arm will have to wait.
Pseudo code/Algorithms/Flowchart/Steps:
1. Let Request array represents an array storing indexes of tracks that have been requested
in ascending order of their time of arrival. ‘head’ is the position of disk head.
2. Let us one by one take the tracks in default order and calculate the absolute distance
of the track from the head.
4. Currently serviced track position now becomes the new head position.
5. Go to step 2 until all tracks in request array have not been serviced.
Step 1: Let Request array represents an array storing indexes of tracks that have been
requested in ascending order of their time of arrival. ‘head’ is the position of disk head.
Step 2: Let direction represents whether the head is moving towards left or right.
Step 3: In the direction in which head is moving service all tracks one by one.
Step 4: Calculate the absolute distance of the track from the head.
Step 5: Increment the total seek count with this distance.
Step 6: Currently serviced track position now becomes the new head position.
Step 7: Go to step 3 until we reach at one of the ends of the disk.
Step 8: If we reach at the end of the disk reverse the direction and go to step 2 u
Implementation:
1. FCFS
int size = 8;
int disk_size = 200;
LEARNING OUTCOMES: -
The students will be able to
i. To select a disk request from the queue of I/O requests and decide the schedule when
this request will be processed.
ii. To Increase the throughput: the average number of requests satisfied per time unit.
iii. To use the hardware efficiently using fast access time and large disk bandwidth that
depends on the relative positions of the read-write head and the requested data.