At time t=2 , Process 1 arrives (Since no time required for Context Switch) , it starts execution and completes execution at Time t = 7.
At time t=7 , Process 2 comes in and due to Context switch it takes 1ms to get into the Running state but at Time t= 8 , Process 3 comes in with less Burst time so now there is Context switch before P2 starts executing(P2 couldn’t even execute for 1ms) and Process 3 enters CPU at Time t = 9 (8 + 1 where 8 is Arrival Time and 1ms for Context switch)
At time t = 9 , Process 3 starts executing till time t= 10 when Process 4 arrives with Burst time 4ms. But since remaining Burst time of Process 3 (2ms) < Burst time of Process 4 < Burst time of Process 2 , there is no context switch and Process 3 continues execution .
At time t = 12 , Process 3 completes execution and there is Context switch , So Process 4 starts execution at time t = 13 .
At time t = 17 , Process 4 completes execution and there is a context switch . So Process 2 starts execution at time t = 18ms.
At time t = 27ms , Process 4 completes execution and since no time taken for Context switch for last process the Completion time is t = 27ms.