Monday, October 5, 2020

Shortest Remaining Time Next Scheduling Algorithm

 


  What is Shortest Remaining Time Next  Algorithm ?  

  This is the preemptive version of Shortest job first algorithm .This permits the process

  that enters the ready list to preempt the running process if the time for the new process

  is less than the remaining time fro the running process. 

  Let us understand this with the help of an example:

 Consider  the set of four process arrived as per timings described in the table

         Process                Arrival Time                           Processing Time

           P1                            0                                                  5

           P2                            1                                                  2

           P3                            2                                                  5

           P4                            3                                                  3


At time 0 only process P1 has entered the system, so its is the process that executes.

At time 1, process P2 arrives. At that time Process P1 has 4 units left to execute.

At this juncture process 2's processing time is less than P1. so P2 starts executing

at  time 1.At time 3 P3 enters the system with the processing time 5 units.Process

P2 continues executing as it has minimum processing time compared to P1 and P3 

both.At time 4 process p2 terminates and process P4 enters the system with time 3

units. Since process P4 has minimum time duration than P1 and P2 process P4 starts

executing. when process P1 terminates at time 10, process P3 enters the system.

The Gantt chart is explained below:


                         P1        P2           P4              P1             P3

                   0            1            3            6               10              15

 

Turn around Time for each of the process is given below:

                  P1 = 10 - 0 = 10

                  P2 =  3 -  1=   2

                  P3 =  15 - 2 = 13

                  P4 =  6 - 3 = 3

Average Turn around Time = 10+2+13+3/4 = 7

 

The waiting time fro each of the process  is  given  as  follows:

                             P1= 10 -5 =5

                             P2 = 2 - 2 =0

                             P3 =13 - 5 =8

                             P4 = 3 - 3 = 0


Average waiting Time =  5+0+8+0/4 = 3.25milliseconds

Four jobs executed in 15 time units, so throughput is 15/4 = 3.75 time units/job

 

 

 

             


No comments:

Post a Comment