The Gateway to Computer Science Excellence
0 votes


Why P1 is still running after 2ms, shouldn't P2 get the cpu burst? In the video they said that are are no processes present other than P1 when the timer interrupts after 2 time slices. Isn't the gantt chart wrong. What i am missing here, can anyone explain it right?

in Operating System by (67 points) | 67 views
yes you are correct its wrong only ...

After P1 we should have have P2 but they have allocated P2 which is not correct

what is the time quantum ? is it 2?

if it is 2, then P1 ( after completing 1st time ) and P2 both are entered into the queue at the same time ( at time=2 )

then it is implementation defined " which one get into the ready queue first. "


yes the time quantum is 2.Since a process is alotted this fixed time, and after 2ms(or whatever the time unit is), process P2 has arrived in the queue, so the scheduler will preempt P1 and push it in the queue after process P2, and process P2 will run for the given time quantum.  The ready queue for first 4 time units will look as :

P1 P2 P1....  when P2 runs P3 arrives before its alloted time has finished...and the queue will be :   

P1 P2 P1 P3.

Hence shouldn't the gantt chart be like this :


brother, read my comment clearly...

note that, at t=2, P1 and P2 both enters into the ready queue at a time. You can't say P2 is coming first and P1 is coming next.
so that's why P1 is continuing to run... P1 is already running and P2 arrives... and the cpu doesn't want a context switch overhead?
actually context switch occurs but again P1 only choosen ( it is implementation defined. )
okk.. i think im getting it.. P1 is already there first at t=2, but i think i've seen examples like this where the other processes are scheduled first.. dont know for sure. can i ask for the source of this implementation.

And thank you so much for replying and clearing doubts.
implementation defned means, while writing program of OS, the programmer write it.

Please log in or register to answer this question.

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,306 answers
105,010 users