Round Robin scheduling using a linked list
<p>I'm trying to implement the Round Robin algorithm for a CPU Scheduler Simulator but using a linked list structure. </p>

<p><strong>I've wrote this code but seems not working as it should be:</strong></p>

<pre><code>//Round Robin scheduling
void roundRobin(){

bubbleSortArrivalTime();

struct process *temp;
int totalTimeCnt=0;
int totalTime;
int quantum=4;
int i;

for(temp=proc; temp!=NULL; temp=temp-&gt;next){
totalTime+=temp-&gt;burstTime;

}

do{


for(i=1; i&lt;LISTSIZE; i++){

if(i==1){
set_nth_process_burstTime(proc, i, get_nth_process_burstTime(proc,i)-quantum);

//set_nth_process_waitingTime(proc, i, get_nth_process_burstTime(proc,i-1)+get_nth_process_waitingTime(proc, i-1));

totalTime+=4;
}

else{
set_nth_process_burstTime(proc, i, get_nth_process_burstTime(proc,i)-quantum);
set_nth_process_waitingTime(proc, i, get_nth_process_burstTime(proc,i-1)+get_nth_process_waitingTime(proc, i-1));
totalTime+=4;
}

}


}while(totalTimeCnt!=0);


method="Method selected: Round Robin Scheduling";


}
</code></pre>

<p><strong>The structure of my linked list is as follows:</strong></p>

<pre><code>    struct process{
    int burstTime,arrivalTime, priority,pname;
    float waitingTime, turnArroundTime;
    struct process *next;
}*proc=NULL;
</code></pre>

<p>where <code>proc</code> is defined as global.</p>

<p><strong>I've implemented some get and set functions to access any element easily:</strong></p>

<pre><code>void set_nth_process_burstTime(struct process*header, int position, int value)
void set_nth_process_waitingTime(struct process *header, int position, float value)
int get_nth_process_waitingTime(struct process *header, int position)
int get_nth_process_priority(struct process *header,int position)
int get_nth_process_arrivalTime(struct process *header,int position)
int get_nth_process_burstTime(struct process *header,int position)
</code></pre>

<p>Could you please advice me on how to implement the Round Robin correctly? It is not giving the correct results.</p>