FCFS scheduling program in C++

Hello frnds, FCFS is a CPU scheduling  algorithm for OS which stands for First Come Fist Serve
Following program is illustrated the FCFS algorithm:-

#include
#include
#define max 20

struct FCFS
{
char proName;
int burstTime;
};

int main()
{
clrscr();
FCFS data[max];
int i,j,n,temp,wTime[max],taTime[max];
float s=0.0,avgTAT=0.0;

//Input data//
//---------------------------------------------------------------------//
cout<<"\nEnter no. of jobs:";
cin>>n;

cout<<"\nEnter name of job:";
for(i=1;i<=n;i++)
{
cin>>data[i].proName;
}

cout<<"\nEnter burst time of each job:";
for(i=1;i<=n;i++)
{
cin>>data[i].burstTime;
}
//------------------------------------------------------------------------//
 

//Evaluating waiting time and turn around time
wTime[1]=0;
for(i=1;i<=n;i++)
{
wTime[i]=s;
s=s+data[i].burstTime;
taTime[i]=s;
}



//Displaying Name, waiting time and turn around time of each process

cout<<"\nJob\tWT\tTAT\n";
for(i=1;i<=n;i++)
{
cout<}

s=0;



//For the calculation of average waiting and turn around time

for(i=1;i<=n;i++)
{
s=s+wTime[i];
avgTAT=avgTAT+taTime[i];
}

avgTAT=avgTAT/n;
s=s/n;
//--------------------------------------------------------------------------------


cout<<"\nAverage waiting time is "<cout<<"\nAverage turn around time is "<getch();
return 0;
}

Popular Posts