FCFS (First Come First Serve) Scheduling Algorithm
What is First Come First Serve Method?
FCFS is an operating system scheduling algorithm that automatically executes queued requests and processes in order of their arrival. It is the easiest and simplest CPU scheduling algorithm. In this type of algorithm, processes which requests the CPU first get the CPU allocation first. This is managed with a FIFO queue. The full form of FCFS is First Come First Serve.
Program For FCFS in C
#include<stdio.h>
#include<conio.h>
void main()
{
int bt[20],wt[20],tat[20],n,i;
float atatsum,awtsum,wtsum=0,tatsum=0;
wt[0]=0;
printf("enter no of process");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("enter burst time for %d th process",i);
scanf("%d",&bt[i]);
}
for(i=1;i<n;i++)
{
wt[i]=bt[i-1]+wt[i-1];
wtsum=wt[i]+wtsum;
}
for(i=0;i<n;i++)
{
tat[i]=wt[i]+bt[i];
tatsum=tat[i]+tatsum;
}
for(i=0;i<n;i++)
{
printf("%d \t %d \t %d \n",i,wt[i],tat[i]);
}
printf("\ntotal \t %f \t %f \n",wtsum,tatsum);
awtsum=wtsum/n;
atatsum=tatsum/n;
printf("\n\navgtotal \t %f \t %f \n",awtsum,atatsum);
getch();
}
Post a Comment