– Scheduling algorithms are used for the purpose of minimizing the phenomena of resource starvation and for ensuring justice among various programs for the better utilization of the resources.
– Scheduling is for dealing with the problems of deciding for which pending requests the resources are to be allocated.
About Shortest Job next Scheduling
– It is also known by many names such as SPN (shortest process next) and SJN (shortest job next).
– This scheduling algorithm goes for the waiting process that would take the least time for next execution.
– Therefore, this algorithm falls in the category of the non–preemptive algorithms.
– Its preemptive variant is the shortest remaining time.
Advantages and Disadvantages of Shortest job next Scheduling
– Shortest job next is very simple and therefore has many advantages.
– It goes a big deal in minimizing the average time for which a process waits at an average until the completion of its execution.
– Apart from all the advantages, its disadvantage is that it can cause process starvation.
– Such a situation will occur for the processes that need a long execution time if there is a continuous addition of the short processes.
– A solution to this problem is provided by the highest response ratio next scheduling algorithm and is somewhat similar to SJN.
– To add to its list of disadvantages, another thing is that the total execution required by a job must be known prior to its execution.
– This is a known fact that the exact execution time cannot be predicted.
– However, there are other methods that consider the weighted average of the previous execution times for estimating a job’s execution time.
– This scheduling algorithm can only be used in particular environments where there is an availability of the accurate estimates of the jobs’ execution time.
– A technique known as aging is used for the estimation of the execution time of the processes that are queued.
About Shortest Remaining Time Scheduling
– A scheduling algorithm similar to SJN is the shortest remaining time scheduling.
– Using this algorithm, the processes having the least execution time remaining can be arranged in the queue and executed turn by turn.
– However, just like SJN, this algorithm also requires a previous estimation of the time that a process would require for its completion.
– If a process with short execution time remains, then the execution of the current process is stopped or preempted and the process is divided in to 2 different blocks.
– This results in excess overhead also because of the additional context switch.
– It is the duty of the scheduler to keep the incoming processes at appropriate positions in the queue.
– Although, this algorithm was meant to produce maximum throughput in a majority of the cases, it turned out that it also led to an increase in the response time and waiting time in proportion with the increase in the computational requirements of the process.
– This has a major effect on the longer processes since turnaround depends up on the sum of processing time and waiting time.
– When compared to the FIFO scheduling, this one takes less overall waiting time since there is no waiting for the termination of the process with longest execution time.
– This algorithm does not care much for the deadlines and so the best a programmer can do is to keep the processes with deadlines as brief as possible.
– The advantage of this scheduling algorithm is in the quick execution of the short processes.
– The overhead caused is very less since only one decision is made when a new process is added or the current one is completed.
– The comparison between the newly added process and the currently executing is all that is required and all other waiting processes are ignored.
– The threat of the starvation can be reduced with the help of a heavy tailed distribution.