Search code examples
algorithmoperating-systemscheduled-tasksschedulinground-robin

how to implement round robin algorithm?


I watch a lot tutorials on youtube about RR scheduling and i had this question in exam but i don't know what i did wrong,the professor solution was different from my solution and i'm now confused.

Job       |    Arrival       |      Burst
P1        |       0          |        4
P2        |       2          |        5
P3        |       3          |        3
P4        |       8          |        4

QT = 1 

Her answer was : P1,P1,P2,P3,P1,P2,P3,P1,P4,P2,P3,P4,P2,P4,P2,P4

My answer was : P1,P1,P2,P1,P3,P2,P1,P3,P2,P4,P3,P2,P4,P2,P4,P4

So which one is the correct answer and if it was her then why ?


Solution

  • Both are correct !!!

    I will say that your solution looks correct( but you are not considering a priority scheduling queue). But it depends how your professor is approaching. Following are the approaches:

    Your Approach:

    You are following normal queue operations. Only enque() and deque(). So using these 2, your approach is correct !!!

    Your Professor's approach:

    Whenever a new process is coming, he is putting it on the top of the queue. He is considering a priority queue instead where every new process has top priority.

    So better if you discuss it with your professor. I would say you are not wrong !!!