charen
charen

Reputation: 371

Round Robin Scheduling Algorithm

So again, doing some scheduling algorithms in JAVA, but the thing is that all the examples i found in the internet don't answer my problem, so i've got nowhere else to ask and i made this post:

What if i have quantum time of 3, and processes:

Name - ArrivalTime - BurstTime
P0 - 0 - 5
P1 - 6 - 5
P2 - 6 - 9
P3 - 8 - 2

So i've found no examples covering that what if the process P1 hasn't arrived, but the quantum ends? So the P0 executes in 3 ms, still has 2ms left, quantum has ended and P1 hasn't arrived. Does the program will wait for P1 or will it complete P0 and still get wait time for 1 ms (until P1 arrives)?

Upvotes: 0

Views: 758

Answers (1)

Gabz
Gabz

Reputation: 134

Scheduling algorithms only schedule processes which are waiting for running.

One execution could be :

T0 : Waiting Process = [P0] ; Executed Process = P0(1-2-3) 
T3 : Waiting Process = [P0] ; Executed Process = P0(4-5) => P0 finished
T5 : Waiting Process = [] ; Executed Process = Nothing
T6 : Waiting Process = [P1, P2] ; Executed Process = P1(1-2-3)
T9 : Waiting Process = [P2, P3, P1] ; Executed Process = P2(1-2-3)
T12 : Waiting Process = [P3, P1, P2] ; Executed Process = P3(1-2) => P3 finished
T14 : Waiting Process = [P1, P2] ; Executed Process = P1(4-5) => P1 finished
T16 : Waiting Process = [P2] ; Executed Process = P2(4-5-6)
T19 : Waiting Process = [P2] ; Executed Process = P2(7-8-9) => P2 finished

On T3, only P0 is waiting for running, so it will be executed for the next quantum of time.

Upvotes: 2

Related Questions