SSTF is the name of an algorithm that comes under Disk Scheduling. SSTF stands for “Shortest Seek Time First” disk scheduling algorithm. In SSTF, the I/O request for which the disk arm requires the least movement is served first. The movement is independent of the direction. In other words, instead of following a particular direction, it goes for the request that is closest to its current position.
One thing to keep in mind before implementing the SSTF algorithm is that the processes having the shortest seek time are prioritised. Even if it arrived late in the ready queue, it is given full priority.
Now if we come to its implementation, the first step is to calculate the seek time of every process beforehand. After that these processes are scheduled in the queue corresponding to the seek time they have.
Let us see it more clearly with an example -
Suppose we have process requests in the order
82, 170, 43, 24,140,190,16
Now suppose that the head is currently situated at 45.
If we arrange all the requests in ascending order then it would go like
0 16 24 43 45 82 100 140 150 170 190
If the head starts from 45 then,
Between 43 and 82, 43 is closer. So it will move to 43 followed by 24 then 16 then 82 then 140 then 170 and finally at 190.
This gives us a total seek time of 208 seconds. The seek time is calculated as the submission of ( final position - initial position) for each request. In SSTF, the requests positioned at the ends of the queue have to wait for a longer time. The overall seek time of the SSTF algorithm is more optimised than the FCFS scheduling algorithm as it serves the request in the order they arrive in.
The system chooses the requests from the current head position that require the least amount of search time.
The SSTF algorithm selects the pending request that is closest to the head position since the seek time grows with the total number of cylinders the head traverses.
The algorithm appears to be sound. Before moving the head far enough away to handle other requests, it completes all of the requests that are near to the current head location. The shortest-seek-time-first (SSTF) algorithm is predicated on this notion.
The entire seek time is short as compared to FCFS.
The tie is broken by SSTF in the direction of head motion.
Throughput is increased as a target of SSTF.
Shortest Seek Time First disk scheduling algorithm has some advantages over the basic FCFS algorithm-
The overall time of average response decreases.
The throughput of the system increases.
A few disadvantages of the Shortest Seek Time First disk scheduling algorithm are-
The seek time needs to be calculated in advance.
If a process that already exists in the queue has a high seek time then it might lead to a condition called starvation.
Only a few requests are favoured because of the high variance in response time.
Disk Scheduling is a process done by the operating systems by which the I/0 requests arrive in a scheduled manner. It is important to have a scheduled system because if multiple I/O requests arrive at the same time the other might need to wait until the first one completes. If two requests have a big difference in their time and in the meanwhile a third request comes which is closer to the first request, the conventional technique might result in a greater movement of the disk arm which is not a good practice. One more thing to notice is that it is important to access the hard disk in an efficient way since it is the slowest part of the computer.
The time taken by the disk arm to shift to a position from where data needs to be read or written is known as the Seek time. If one process is at 45 and the other is at 50, then the time taken by the disk arm to reach 50 from 45 will be the seek time.
FCFS stands for “First Come First Serve” disk scheduling algorithm. It is the simplest algorithm in which the requests are served just in the order they arrive. If the order of requests is 24, 95 and 30 then they will be served in the same order. The high movement of the disk arm is not taken into consideration in this algorithm.
The throughput of a system is defined as the units of information it can process in a given time.
Starvation is the condition when the processes having high priority keep entering the queue and the low priority processes do not get the chance to be executed for an unknown amount of time.