round robin algorithm - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

round robin algorithm

ioriiori Posts: 59Member
round robin is a cpu scheduling algorithm. here is what i am trying to do. say example there are 2 processes p1 and p2 in the readyQueue contending for CPU. each process has an array of cpu bursts and io bursts for example:

process cpu burst io burst cpu burst
------- --------- -------- ---------
p1 5 1 4
p2 12 10 3

and a timequantum/timeslice of 4.

please check this link to see what i am talking about.

here is what i have now for the alogrithm, plz check and let me know if its correct or not:

struct PCB
int cpuBurst[20];
int ioBurst[20];
int totalCPUBursts;
int totalIOBursts;

int waitTime;
int completionTime;
int arrivalTime;
int startTime;


put all processes on readyQueue as they come in
while not done
if readyQ is not empty
dequeue the process from readyQueue
read totalCPUBursts
if cpuBurst[currentCPUBurst]>=timeslice
enqueue this process to readyQueue
else if cpuBurst[currentCPUBurst]=timeslice
enqueue this process to readyQueue
else if ioBurst[currentIOBurst]<timeslice
enqueue this process to ready Queue

if readyQ and blockedQ are empty
all process done so exit while

Sign In or Register to comment.