Shortest Job First in Operating System

As the name itself says that the shortest is having the least burst time we are going to show you that first that is right in shortest job first and it is of two variations one is preemptive and other one is non pre-emptive and coming to this this one here I am using non pre-emptive which means whenever any job is chosen it will not stop until it finishes that is where it is called non pre-emptive and the other one is the pre-emptive version is there which is also called as shortest remaining job next.
whenever you choose any process you are going to run it till completion otherwise you are not going to stop okay now let us see how to how to do this first one is like this first one is I am going to use the Gantt chart starting at zero so at zero is any process available arrival time is minimum is 1 therefore no cross is actually a verbal at 0 so until 1 so the first process which will be available will be at time 1 therefore from 0 to 1 CPU is idle now at time 1 the only process available is p1 therefore I am going to take p1 and run it till completion the reason is it is non pre-emptive version right so how much time does it take for it to complete seven minutes therefore it is 1 plus 7 is 8 so now the time is 8 by the time wait all the other process are available in case if they are not available.
Then you have to pick one of the available processes for they should you always remember this whenever you are trying to pick the next one you see that you pick the next available process for scheduling right and now 1 2 8 is over therefore you have to pick one from the available one right so from all these which one is know which one is the best one from all these the deist one is p3 see p1 is over therefore the least one is p3 which is having a burst M of 1 therefore I am going to take p3 next p3 it is having a burst time of 1 that word is going to be running till right now p3 is over then what is the next one with the least burst M which is 2 therefore p4 which is having a burst M of 2 therefore the completion time is 11 right and now I have 3 1 is 2 and other is 5 I think I have to process 1 3 4 or over 1 3 4 or over I have 2 and 5 and in these two which one is having the least burst time if you watch it the least burst time is it p2 therefore I am going to take P 2 and we whose burst and is 5 therefore 11 plus 5 is 16 and obviously only one is remaining and it is already available at 16 right P 5 which is 8 what it so 16 plus 8 is how much 24 okay now if we observe it even though it is shortest wave in shortest job first when you have these many jobs the question might be given initiative given any random combination of process with random possible arrival times our shortest job will always showed you the shortest job first it is false the reason is it is actually scheduling among the available process the shortest job first which means when you are loop in your standing at time 1 at this point of time one only process which is available is p1 that is what is chosen.

Leave a Comment