FCFS CPU Scheduling Algorithm with given arrival Time

Program No. 5

Aim: Program to implement FCFS CPU Scheduling Algorithm with given arrival Time

Logic:
#include
#include
void main()
{
int n, bt[10],i,j, twt=0, ttat=0,p[10], temp2,at[10],temp3, CT[10];
float awt, atat;
int  wt[10], tat[10];
clrscr();
printf("\n enter the total no. of processes  ");
scanf("%d",& n);

for(i=0; i
{
printf("enter process number");
scanf("%d", &p[i]);
printf(" enter the burst time  ");
scanf("%d", &bt[i]);
printf(" enter the arrival time ");
scanf("%d",&at[i]);
}

for(i=0;i
{
for(j=i+1;j
{
if(at[i]>at[j])
{
int temp1;
temp1=bt[i];
bt[i]=bt[j];
bt[j]=temp1;

temp2=at[i];
at[i]=at[j];
at[j]=temp2;

temp3=p[i];
p[i]=p[j];
p[j]=temp3;
}
}
}
CT[0]=0;
for(i=0;i
{
CT[i+1]=CT[i]+bt[i];
}
for(i=0;i
{
 tat[i]=CT[i+1]-at[i];
 wt[i]=tat[i]-bt[i];
}
printf("\n\tprocess\tBT\tWT\tTAT\tAT\n");
 for (i=0; i
{
twt=twt+wt[i];
ttat=ttat+tat[i];

}
for(i=0;i
{
printf("\tP[%d]\t%d\t%d\t%d\t%d\n",p[i],bt[i],wt[i],tat[i],at[i]);
}
awt=twt/n;
atat=ttat/n;
printf("\naverage waiting time is %f", awt);
printf("\naverage turn around time is %f", atat);
getch();

}

Output:





Download

BY:
PROF. CHETNA PATEL
TSEC BURHANPUR


Related topics

Professor Jayesh video tutorial

Please use contact page in this website if you find anything incorrect or you want to share more information about the topic discussed above.