Breaking News
recent

Program for FCFS Scheduling in C | CS331 System Software Lab

Aim:Implement First Come First Served (FCFS) Scheduling
KTU FCFS
Given n processes with their burst times, the task is to find average waiting time and average turn around time using FCFS scheduling algorithm. First in, first out (FIFO), also known as first come, first served (FCFS), is the simplest scheduling algorithm. FIFO simply queues processes in the order that they arrive in the ready queue. In this, the process that comes first will be executed first and next process starts only after the previous gets fully executed.
"If you got error! please comment below."
Program for FCFS Scheduling in C
#include<stdio.h>
main()
{
int n,a[10],b[10],t[10],w[10],g[10],i,m;
float att=0,awt=0;
for(i=0;i<10;i++)
        {
a[i]=0; b[i]=0; w[i]=0; g[i]=0;
        }
printf("Enter the number of process=");
scanf("%d",&n);
printf("Enter the burst times=");
for(i=0;i<n;i++)
scanf("%d",&b[i]);
printf("\nEnter the arrival times=");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
g[0]=0;
for(i=0;i<10;i++)
g[i+1]=g[i]+b[i];
for(i=0;i<n;i++)
        {
w[i]=g[i]-a[i];
t[i]=g[i+1]-a[i];
awt=awt+w[i];
att=att+t[i];
        }
awt =awt/n;
att=att/n;
printf("\n\tprocess\t\twaiting time\t\tturn arround time\n");
for(i=0;i<n;i++)
        {
printf("\t\tp%d\t\t\t%d\t\t\t%d\n",i,w[i],t[i]);
        }
printf("Average waiting time is= %f\n",awt);
printf("Average turn around time is= %f\n",att);
}

No comments:

Powered by Blogger.