#include<stdio.h>
#include<conio.h>
void main()
{
int bt[3],at[3],tq;
int ft[3],tat[3];
int ec={0,0,0},i,bt1[3];
char p[3][9];
clrscr();
printf("\nEnter the process and burst-time:");
for(i=0;i<3;i++)
{
scanf("%s%d",p[i],&bt[i]);
bt1[i]=bt[i];
}
printf("\nEnter the arrival-time:");
for(i=0;i<3;i++)
scanf("%d",&at[i]);
printf("\nEnter the time quantum:");
scanf("%d",&tq);
b=0;
while(ec[0]!=1||ec[1]!=1||ec[2]!=1)
for(i=0;i<3;i++)
if(ec[i]==0)
{
if(bt[i]<=tq)
{
ft[i]=b+bt[i];
b=ft[i];
ec[i]=1;
}
else
{
b=b+tq;
bt[i]=bt[i]-tq;
}
}
for(i=0;i<3;i++)
tat[i]=ft[i]-at[i];
printf("\nROUND ROBIN SCHEDULING\n");
printf("\nProcess Burst-time Arrival-time
Finish-time Turnaround-time");
for(i=0;i<3;i++)
printf("\n%d%s\t\t%d\t\t%d\t\t%d\t\t%d",
i+1,p[i],bt[i],at[i],ft[i],tat[i]);
}
/*OUTPUT FOR ROUND-ROBIN*/
INPUT:
Enter the process and burst-time:
p1 24
p2 3
p3 4
Enter the arrival-time:
1
2
3
Enter the quantum:
5
OUTPUT:
ROUND ROBIN SCHEDULING
Process Burst-time Arrival-time Finish-time Turnaround-time
1 p1 4 1 31 30
2 p2 3 2 8 6
3 p3 4 3 12 9
If you like this please Link Back to this article...
0 comments:
Post a Comment