Lesson 2.4 Disk Arm Scheduling
Lesson 2.4 Disk Arm Scheduling
One of the functions of the OS is to schedule requests for disk. The request could be a read
request to read data from disk or a write request to write to disk. These requests are called
input/output requests for disk. Multiple I/O requests for the disk can arrive, but only one
request can be served at a time. Hence, the question would be “Which request will be served
first?”. It is the responsibility of the OS to make decisions of which I/O request for the disk is
serviced first. The OS makes use of a disk scheduling algorithm to make such a decision.
These algorithms help the OS to maintain an efficient manner in which input-output requests
can be managed to execute a process. It manages a proper order to deal with sequential
requests to the disk and provide the required data. Since multiple requests are approaching
the disk, the algorithm also manages the upcoming requests of the future and does a lining up
of requests.
1
Disk Scheduling Terms
❖ Seek Time: Seek time is the time taken to locate the disk arm to a specified track
where the data is to be read or written. So the disk scheduling algorithm that gives
minimum average seek time is better.
❖ Rotational Latency: Rotational Latency is the time taken by the desired sector of
disk to rotate into a position so that it can access the read/write heads. So the disk
scheduling algorithm that gives minimum rotational latency is better.
❖ Transfer Time: Transfer time is the time to transfer the data. It depends on the
rotating speed of the disk and number of bytes to be transferred
❖ Disk Access Time: It is defined as the total time taken by all the above processes.
Disk access time = (seek time + rotational latency time + transfer time)
❖ Disk Response Time: The disk processes one request at a single time. So, the other
requests wait in a queue to finish the ongoing process of request. The average of this
waiting time is called "Disk Response Time".
❖ Starvation: Starvation is defined as the situation in which a low-priority job keeps
waiting for a long time to be executed. The system keeps sending high-priority jobs to
the disk scheduler to execute first.
There are several disk scheduling algorithms. Below is a list of some of them:
❖ First Come First Serve (FCFS)
❖ Shortest Seek Time First (SSTF)
❖ SCAN
❖ CSCAN
❖ LOOK
❖ CLOOK
FCFS
The requests are addressed in the order they arrive in the disk queue. the request which comes
first will be processed first and so on. The requests coming to the disk are arranged in a
2
proper sequence as they arrive. Since every request is processed in this algorithm, there is no
chance of 'starvation'.
Example
Disk request arrive in the following order:
82,170,43,140,24,16,190 and the current position of Read/Write head is: 50. The disk has 200
tracks. Using FCFS algorithm, these requests will be serviced as shown on the diagram
below:
In the above diagram, we can see the head starts at position 50 and moves to request 82. After
serving request 82, the disk arm moves towards the second request that is 170 and then to the
request 43 and so on. In this algorithm, the disk arm will serve the requests in arriving order.
In this way, all the requests are served in arriving order until the process executes. Seek time"
is calculated by adding the head movement differences of all the requests:
Seek time= "(82-50) + (170-82) + (170-43) + (140-43) + (140-24) + (24-16) + (190-16) = 642
Advantages:
Disadvantages:
3
❖ May not provide the best possible service
SSTF
Requests having the shortest seek time are executed first. So, the seek time of every request is
calculated in advance in the queue and then they are scheduled according to their calculated
seek time. As a result, the request near the disk arm will get executed first. SSTF is certainly
an improvement over FCFS as it decreases the average response time and increases the
throughput of the system.
Example
Order of requests:82,170,43,140,24,16,190, current read/write head position is 50, and disk
has 200 tracks.
The disk arm searches for the request which will have the least difference in head movement.
So, the least difference is (50-43). Here the difference is not about the shortest value but it is
about the shortest time the head will take to reach the nearest next request. So, after 43, the
head will be nearest to 24, and from here the head will be nearest to the request 16, After 16,
the nearest request is 82, so the disk arm will move to serve request 82 and so on.
Seek Time = (50-43) + (43-24) + (24-16) + (82-16) + (140-82) + (170-140) + (190-170) = 208
Advantages:
4
❖ Overhead to calculate seek time in advance
❖ Can cause Starvation for a request if it has a higher seek time as compared to
incoming requests
❖ High variance of response time as SSTF favours only some requests
SCAN
In the SCAN algorithm the disk arm moves in a particular direction and services the requests
coming in its path and after reaching the end of the disk, it reverses its direction and again
services the request arriving in its path. So, this algorithm works as an elevator and is hence
also known as an elevator algorithm. As a result, the requests at the midrange are serviced
more and those arriving behind the disk arm will have to wait.
Example:
In the diagram above, we can see that the disk arm starts from position 50 and goes in a
single direction until it reaches the end of the disk, i.e, request position 199. After that, it
reverses and starts servicing in the opposite direction until it reaches the other end of the disk.
Advantages:
5
● High throughput
● Low variance of response time
● Average response time
Disadvantages:
● Long waiting time for requests for locations just visited by disk arm
CSCAN
In the SCAN algorithm, the disk arm again scans the path that has been scanned, after
reversing its direction. So, it may be possible that too many requests are waiting at the other
end or there may be zero or few requests pending at the scanned area. These situations are
avoided in the CSCAN algorithm in which the disk arm instead of reversing its direction goes
to the other end of the disk and starts servicing the requests from there. So, the disk arm
moves in a circular fashion and this algorithm is also similar to the SCAN algorithm and
hence it is known as C-SCAN (Circular SCAN).
Example:
Suppose the requests to be addressed are-82,170,43,140,24,16,190. And the Read/Write arm
is at 50, and it is also given that the disk arm should move “towards the larger value”.
6
The disk arm starts from position 50 and reaches the end(199), and serves all the requests in
the path. Then it reverses the direction and moves to the other end of the disk i.e.- 0 without
serving any task in the path. After reaching 0, it will again move towards the largest
remaining value which is 43. So, the head will start from 0 and moves to request 43 serving
all the requests coming in the path. And this process keeps going.
Advantages:
Disadvantages:
❖ The time taken by the disk arm to locate a spot is increased here.
❖ The head keeps going to the end of the disk.
LOOK
It is similar to the SCAN disk scheduling algorithm except for the difference that the disk
arm in spite of going to the end of the disk goes only to the last request to be serviced in front
of the head and then reverses its direction from there only. Thus it prevents the extra delay
which occurred due to unnecessary traversal to the end of the disk.
Example:
Suppose the requests to be addressed are-82,170,43,140,24,16,190. And the Read/Write arm
is at 50, and it is also given that the disk arm should move “towards the larger value”.
7
The disk arm is starting from 50 and starts to serve requests in one direction only but instead
of going to the end of the disk, it goes to the end of requests i.e.-190. Then comes back to the
last request of other ends of the disk and serves them. And again starts from here and serves
till the last request of the first.
Seek time = (190-50) + (190-16) =314
Advantages:
❖ Starvation does not occur.
❖ Since the head does not go to the end of the disk, the time is not wasted here.
Disadvantage:
❖ The arm has to be conscious to find the last request.
CLOOK
Example:
1. Suppose the requests to be addressed are-82,170,43,140,24,16,190. And the
Read/Write arm is at 50, and it is also given that the disk arm should move
“towards the larger value”
8
The disk arm is starting from 50 and starts to serve requests in one direction only but in spite
of going to the end of the disk, it goes to the end of requests i.e.-190. Then comes back to the
last request of other ends of a disk without serving them. And again starts from the other end
of the disk and serves requests of its path.
Seek Time = (190-50) + (190-16) + (43-16) =341
Advantages:
The waiting time is decreased.
If there are no requests till the end, it reverses the head direction immediately.
Starvation does not occur.
The time taken by the disk arm to find the desired spot is less.
Disadvantage:
The arm has to be conscious about finding the last request.