#include<stdio.h>
#include<conio.h>
void main()
{
int bt[3],wt[3],at[3],ft[3],tat[3];
int i,n,sum=0;
float awt;
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]);
printf("\nEnter the arrival-time:");
for(i=0;i<3;i++)
scanf("%d",&at[i]);
wt[0]=0;
for(i=1;i<3;i++)
wt[i]=wt[i-1]+bt[i-1];
ft[0]=bt[0];
for(i=1;i<3;i++)
ft[i]=ft[i-1]+bt[i];
for(i=0;i<3;i++)
tat[i]=ft[i]-at[i];
for(i=0;i<3;i++)
sum=sum+wt[i];
awt=sum/3.0;
printf("\n FIRST COME,FIRST SERVE\N");
printf("\n Process Burst-time Arrival-time Waiting-time
Finish-time Turnaround-time\n");
for(i=0;i<3;i++)
printf("\n\n %d%s\t %d\t %d\t\t %d\t %d\t\t %d",
i+1,pi[],bt[i],at[i],wt[i],ft[i],tat[i]);
printf("\n\nAverage waiting time:%f",awt);
}
/*OUTPUT FOR FCFS*/
INPUT:
Enter the process and burst-time:
process1 10
process2 20
process3 30
Enter the arrival-time:
1
2
3
OUTPUT:
FIRST COME,FIRST SERVE
Process Burst-time Arrival-time Waiting-time Finish-time Turnaround-time
process1 10 1 0 10 9
process2 20 2 10 30 28
process2 30 3 30 60 57
If you like this please Link Back to this article...
0 comments:
Post a Comment