Difference between SSTF and LOOK Disk Scheduling Algorithm
Operating systems do disk scheduling to schedule I/O requests arriving for the disk. Disk scheduling is also known as I/O scheduling. The goal of disk scheduling algorithms is to maximize the throughput and minimize the response time. Here are six different disk scheduling algorithms, such as First Come First Serve (FCFS), Shortest Seek Time First (SSTF), Scan, Look, C-Scan, and C-look disk scheduling by comparing their head movement in different runs.
What is SSTF Disk Scheduling Algorithm?
SSTF stands for Shortest Seek Time First. This algorithm serves the task request, which is closest to the current position of the head or pointer. Here, the direction of the head plays a vital role in determining total head movement. If a tie occurs between requests, then the head will serve the request, which encounters it in its ongoing direction. Unlike C-LOOK, the SSTF algorithm is very efficient in total seek time.
In 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 when 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.
It is a reasonable solution for a batch processing system. Sometimes, it does not ensure fairness because, with this scheduling, starvation is possible. This policy is generally not acceptable for interactive systems, and it leads to higher variances of response times.
Example
In this case, the request is serviced according to the next shortest distance.
Starting at 50, the next shortest distance would be 62 instead of 34 since it is only 12 tracks away from 62 and 16 tracks away from 34. The process would continue until all the processes are taken care of. For example, the next case would be to move from 62 to 64 instead of 34 since there are only 2 tracks between them and not 18 if it were to go the other way.
Although this seems to be a better service because it moved all 236 tracks, it is not optimal. There is a great chance that starvation would occur, and this is because if there were many requests close to each other, the other requests would never be handled since the distance would always be greater.
Advantages
Here are the following advantages of the SSTF Disk Scheduling Algorithm, such as:
- It reduces the total seek time as compared to FCFS.
- It provides increased throughput
- , and it provides less average response time and waiting time.
Disadvantages
SSTF Disk Scheduling Algorithm also has the following disadvantages, such as:
- There is an overhead of finding out the closest request.
- And the requests which are far from the head might starve for the CPU.
- It provides a high variance in response time and waiting time.
- Switching the direction of the head frequently slows down the algorithm.
What is the LOOK Disk Scheduling Algorithm?
LOOK algorithm is actually an improved version of the SCAN Algorithm. In this algorithm, the head starts the first request at one side of the disk and moves towards the other end by serving all requests in between. Unlike SCAN, the head, instead of going till the last track, goes till the last request, and then the direction is changed. Unlike SSTF, it doesn’t serve the task request which is closest to the current position of the head or pointer.
It is similar to the SCAN disk scheduling algorithm except for the difference that the disk arm, despite 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. The main difference between the SCAN Algorithm and LOOK algorithm is:
- SCAN Algorithm scans all the cylinders of the disk starting from one end to the other end even if there are no requests at the ends.
- LOOK Algorithm scans all the cylinders of the disk starting from the first request at one end to the last request at the other end.
Example
Consider a disk with 200 tracks (0-199) and the disk queue having I/O requests in the following order: 98, 183, 40, 122, 10, 124, and 65.
The current head position of the ReadWrite head is 53 and will move in the right direction. Calculate the total number of track movements of the Read/Write head using the LOOK algorithm.
Advantages of LOOK Disk Scheduling Algorithm
Here are the following advantages of the LOOK disk scheduling algorithm, such as:
- It does not cause the head to move till the ends of the disk when there are no requests to be serviced.
- It provides better performance as compared to the SCAN Algorithm.
- It does not lead to starvation.
- It provides low variance in response time and waiting time.
Disadvantages of LOOK Disk Scheduling Algorithm
Look disk scheduling algorithm also has some disadvantages, such as:
- There is an overhead of finding the end requests.
- And it causes a long waiting time for the cylinders just visited by the head.
Difference between SSTF and LOOK Disk Scheduling Algorithm
Below are the following differences between SSTF and LOOK disk scheduling algorithm.
SSTF Disk Scheduling Algorithm | LOOK Disk Scheduling Algorithm |
---|---|
SSTF disk scheduling algorithm lags in performance. | The performance of the LOOK disk scheduling algorithm is better than SSTF. |
It reduces total seek time as compared to the LOOK disk scheduling algorithm. | LOOK disk scheduling algorithm is increased total seek time. |
This algorithm provides high variance average response time and waiting time. | It provides low variance in average waiting time and response time. |
As shown in the above example, the direction of the head plays an important role in breaking the tie between requests. | In the LOOK disk scheduling algorithm, the direction of the head gets reversed when it serves the last request in one direction. |
In the SSTF disk scheduling algorithm, there is an overhead for finding out the closest request. | In this algorithm, there is an overhead for finding end requests. |
In the SSTF disk scheduling algorithm, the request which is far from the head will suffer starvation. | LOOK disk scheduling algorithm does not cause starvation to any request. |
In the SSTF disk scheduling algorithm, the handling of requests is not as good as the LOOK algorithm. | LOOK disk scheduling algorithm can handle requests more effectively than SSTF. |
SSTF Scheduling has higher throughput and lower response time than FCFS Policy. | The main advantage of this scheduling is that it only performs sweeps large enough to service all requests. It improves efficiency by avoiding unnecessary seek operation, and it gives high throughput. |