Shortest Job First (SJF) scheduling algorithm: It is a non preemptive scheduling algorithm which is used for batch systems. This algorithm works only when all the jobs are available at a particular time. In this algorithm the shortest job is picked form the queue and is run first. After that the next shortest job is picked and so on. Consider 5 jobs A, B, C, D, and E having a running time of 2, 4, 6, 8, and 10 minutes respectively.
So, according to the below given order of their running, The turnaround time for A is 30 minutes, B is 28 minutes, C is 24 minutes, D is 18 minutes, and E is 10 minutes. The average time of run for each job is (30 + 28 + 24 + 18 + 10)/5 = 22 minutes.
Now, if we apply the Shortest Job First algorithm:
The turnaround time for A is 2 minutes, B is 6 minutes, C is 12 minutes, D is 20 minutes, and E is 30 minutes. The average time of run for each process is (2 + 6 + 12 + 20 + 30)/5 = 14 minutes.
Shortest Remaining Time Next (SRTN) scheduling algorithm: It is a preemptive form of Shortest Job First (SJF) scheduling algorithm. In this algorithm a job is chosen whose remaining run time is the shortest. For a new job, its run time is compared with remaining time of current job. If new job needs less time to complete than the current job, then, the current job is blocked and the new job is run. It is used for batch systems and provides advantages to new jobs.