You are on page 1of 4

What is first come first serve(FCFS)?

First Come, First Served (FCFS) is a type of scheduling algorithm used by operating systems and
networks to efficiently and automatically execute queued tasks, processes and requests by the order
of their arrival. An FCFS scheduling algorithm may also be referred to as a first-in, first-out (FIFO)
algorithm or a first-come, first-choice (FCFC) algorithm.

Due to its simplistic nature, an FCFS algorithm is predictable, regardless of the type of tasks or
requests it has to process. Like a grocery store checkout scheme, FCFS algorithms mimic real-life
customer service situations where patrons who arrive first get served first regardless of the size and
complexity of their interaction.

First Come, First Served is one of the most efficient and autonomous types of scheduling algorithm
because it requires little-to-no human or artificial intelligence intervention and does not waste time
prioritizing tasks and requests by their urgency or level of complexity. Additionally, the party
responsible for the scheduling is the CPU itself instead of software or an alternate, more
complex algorithim.

Implementation-:
process Arrival Burst time Completion tat
time time
0 0 2 2 2
1 3 6 9 6
2 4 4 13 9
3 5 9 22 17
4 6 12 34 28

CODE-:

#include<bits/stdc++.h>

using namespace std;

int main() {

int att[5]={0,3,4,5,6};

int btt[5]={2,6,4,9,12};
int ctt[5];

int tat[5];

int wtt[5];

ctt[0]=btt[0]+att[0];

tat[0]=ctt[0]-att[0];

wtt[0]=tat[0]-btt[0];

for(int i=1;i<5;i++)

int sum=0;

if(att[i]<=ctt[i-1]) {

sum=ctt[i-1]+btt[i];

}else{

sum=att[i]+btt[i];

ctt[i]=sum;

tat[i]=ctt[i]-att[i];

wtt[i]=tat[i]-btt[i];

cout<<"process at bt ct tat wt"<<endl;

for(int i=0;i<5;i++) {

cout<<i<<" "<<att[i]<<" "<<btt[i]<<" "<<ctt[i]<<" "<<tat[i]<<" "<<wtt[i]<<endl

return 0;

}
Case 2:
process Arrival Burst Completion tat wt
time time time
0 2 2 9 9 0
1 5 6 12 12 8
2 1 4 13 13 11
3 0 9 23 23 11
4 4 12 28 28 22

CODE:

#include<bits/stdc++.h>

using namespace std;

int main()

int att[5]={2,5,1,0,4};

int btt[5]={2,6,4,9,12};

int process[5]={0,1,2,3,4};

for(int i=0;i<5;i++)

for(int j=0;j<5;j++)

if(att[i]<att[j])

swap(att[i],att[j]);

swap(btt[i],btt[j]);

swap(process[i],process[j]);

}
}

int ctt[5];

int tat[5];

int wtt[5];

ctt[0]=btt[0]+att[0];

tat[0]=ctt[0]-att[0];

wtt[0]=tat[0]-btt[0];

for(int i=1;i<5;i++)

int sum=0;

if(att[i]<=ctt[i-1])

sum=ctt[i-1]+btt[i];

}else{

sum=att[i]+btt[i];

ctt[i]=sum;

tat[i]=ctt[i]-att[i];

wtt[i]=tat[i]-btt[i];

cout<<"process at bt ct tat wt"<<endl;

for(int i=0;i<5;i++)

cout<<i<<" "<<att[i]<<" "<<btt[i]<<" "<<ctt[i]<<" "<<tat[i]<<" "<<wtt[i]<<endl;

return 0;

You might also like