0% found this document useful (0 votes)
9 views2 pages

Round Robin Scheduling in C

This C program implements a round robin scheduling algorithm for process management. It prompts the user to input the number of processes, their arrival and burst times, and the time quantum. The program then calculates and displays the waiting time and turnaround time for each process based on the round robin scheduling method.

Uploaded by

jeletol194
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Round Robin Scheduling in C

This C program implements a round robin scheduling algorithm for process management. It prompts the user to input the number of processes, their arrival and burst times, and the time quantum. The program then calculates and displays the waiting time and turnaround time for each process based on the round robin scheduling method.

Uploaded by

jeletol194
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

// round robin scheduling program in c

#include<stdio.h>

void main()
{
int i, NOP, sum=0,count=0, y, quant, wt=0, tat=0, at[10], bt[10], temp[10];
float avg_wt, avg_tat;
printf(" Total number of process in the system: ");
scanf("%d", &NOP);
y = NOP;

for(i=0; i<NOP; i++)


{
printf("\n Enter the Arrival and Burst time of the Process[%d]\n", i+1);
printf(" Enter Arrival time: \t");
scanf("%d", &at[i]);
printf(" \nEnter Burst time: \t");
scanf("%d", &bt[i]);
temp[i] = bt[i];
}

printf("Enter the Time Quantum for the process: \t");


scanf("%d", &quant);
printf("\n Process No \t\t Burst Time \t\t TAT \t\t Waiting Time ");
for(sum=0, i = 0; y!=0; )
{
if(temp[i] <= quant && temp[i] > 0)
{
sum = sum + temp[i];
temp[i] = 0;
count=1;
}
else if(temp[i] > 0)
{
temp[i] = temp[i] - quant;
sum = sum + quant;
}
if(temp[i]==0 && count==1)
{
y--;
printf("\nProcess No[%d] \t\t %d\t\t\t\t %d\t\t\t %d", i+1, bt[i], sum-at[i], sum-at[i]-bt[i]);
wt = wt+sum-at[i]-bt[i];
tat = tat+sum-at[i];
count =0;
}
if(i==NOP-1)
{
i=0;
}
else if(at[i+1]<=sum)
{
i++;
}
else
{
i=0;
}
}
}

You might also like