It is a preemptive version of SJF algorithm where the remaining processing time is considered for assigning CPU to the next process.

Now we add the concepts of varying arrival times and preemption to the analysis

Process Arrival Time Burst Time
P1 0 8
P2 1 4
P3 2 9
P4 3 5

Preemptive SJF Gantt Chart

Average waiting time

= [(10-1) +(1-1) +(17-2) +5-3)]/4

= 26/4

= 6.5 milliseconds