C program for round robin scheduling algorithm.

Posted by Mangesh on June 17, 2018

Description :

Each process gets a small unit of CPU time (time quantum ). After this time has elapsed, the process is preempted and added to the end of the ready queue. If there are n processes in the ready queue and the time quantum is q, then each process gets 1/n of the CPU time in chunks of at most q time units at once. No process waits more than (n-1) q time units. Run process for a time slice then move to FIFO.

Program :

void main()
 int bursttime[100],waitingtime[100],turnaroundtime[100],b[100];
 int i,n,time,count=0;
 float totalwt=0,totalTT=0,avgwt,avgtt;
 printf("Enter total number of process : ");
  printf("\nEnter the burst time of %d process : ",i+1);
  b[i] = bursttime[i];
   while(bursttime[i] == 0)
     turnaroundtime[i] = time+1;
   i = (i+1)%n;
 printf("\nprocess   burst   waitng   turnaround   ");
 {  waitingtime[i] = turnaroundtime[i] - b[i];
    printf("\n   %d \t    %d \t     %d \t    %d",i+1,b[i],waitingtime[i],turnaroundtime[i]);
    totalwt = totalwt + waitingtime[i];
    totalTT = totalTT + turnaroundtime[i];
 printf("\n  %d  %f  %f",n,totalwt,totalTT);
 avgwt = totalwt / n;
 avgtt = totalTT / n;
 printf("\nAverage waiting time is %f",avgwt);
 printf("\nAverage turnaround time is %f ",avgtt);

Output :

c program for round robin scheduling Executed and Tested in Turbo C 3.2

Written with from Mangesh.

Related Post
1 C program for first come first serve scheduling.
2 C program for shortest job first scheduling algorithm.
3 C program for shortest remaining time first scheduling algorithm.
4 C program for round robin scheduling algorithm.
Latest Post
1 shubhanshu
2 test
3 C program for Breadth First Search.
4 C program for Depth First Search(DFS).
5 C for circular queue using linked list.