C Program to show and example for FCFS scheduling
#include<stdio.h>
void main()
{
int i,k,s=0,r=0,x=0,a[30],t[30],w[30],e[30];
float n,m,p=0;
printf("Enter the number of process: ");
scanf("%f",&n);
printf("Enter the execution time: ");
for(i=0;i<n;i++)
{
printf("i=%d n=%f\n",i,n);
scanf("%d",&a[i]);
e[i]=a[i];
}
printf("After First come First serve scheduling: \n");
w[0]=0;
t[0]=a[0];
for(i=1;i<n;i++)
{
w[i]=t[i-1];
t[i]=t[i-1]+a[i];
}
printf("Process \tBurst Time \tTurn Around Time \n");
float tt=0,wt=0;
for(i=0;i<n;i++)
{
printf("%d \t\t %d \t\t %d \t\t %d \t\t \n",i+1,e[i],w[i],t[i]);
tt=tt+t[i];
wt=wt+w[i];
}
printf("Average waiting time=%f\n",wt/n);
printf("Average turn around time=%f\n",tt/n);
}
Comments
Post a Comment