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

Name: Rohit Mavle Comps: T.E-A3 Roll No-67: Program

The document contains a C program to implement Round Robin Scheduling algorithm. It takes the burst time of processes as input, calculates their waiting time and turnaround time, and outputs the average waiting time and average turnaround time. The program contains variables to store processes details like burst time, waiting time, turnaround time. It uses a time quantum to simulate the Round Robin algorithm.

Uploaded by

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

Name: Rohit Mavle Comps: T.E-A3 Roll No-67: Program

The document contains a C program to implement Round Robin Scheduling algorithm. It takes the burst time of processes as input, calculates their waiting time and turnaround time, and outputs the average waiting time and average turnaround time. The program contains variables to store processes details like burst time, waiting time, turnaround time. It uses a time quantum to simulate the Round Robin algorithm.

Uploaded by

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

Name: ROHIT MAVLE

COMPS: T.E-A3
Roll No- 67

Program:

#include<stdio.h>
#include<conio.h>
main()
{
int st[10],bt[10],wt[10],tat[10],n,tq;
int i,count=0,swt=0,stat=0,temp,sq=0;
float awt=0.0,atat=0.0;
printf("Enter number of processes:");
scanf("%d",&n);
printf("Enter burst time for sequences:");
for(i=0;i<n;i++)
{
scanf("%d",&bt[i]);
st[i]=bt[i];
}
printf("Enter time quantum:");
scanf("%d",&tq);
while(1)
{
for(i=0,count=0;i<n;i++)
{
temp=tq;
if(st[i]==0)
{
count++;
continue;
}
if(st[i]>tq)
st[i]=st[i]-tq;
else
if(st[i]>=0)
{
temp=st[i];
st[i]=0;
}
sq=sq+temp;
tat[i]=sq;
}
if(n==count)
break;
}
for(i=0;i<n;i++)
{
wt[i]=tat[i]-bt[i];
swt=swt+wt[i];
stat=stat+tat[i];
}
awt=(float)swt/n;
atat=(float)stat/n;
printf("Process_no Burst time Wait time Turn around time\n");
for(i=0;i<n;i++)
printf("%d\t\t%d\t%d\t%d\n",i+1,bt[i],wt[i],tat[i]);
printf("Avg wait time is %f Avg turn around time is %f",awt,atat);
getch();
}

Output:

You might also like