What is First Come First Serve Method?
First Come First Serve (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.
As the process enters the ready queue, its PCB (Process Control Block) is linked with the tail of the queue and, when the CPU becomes free, it should be assigned to the process at the beginning of the queue.
Characteristics of FCFS Scheduling
- It supports non-preemptive and pre-emptive scheduling algorithm.
- Jobs are always executed on a first-come, first-serve basis.
- It is easy to implement and use.
- This method is poor in performance, and the general wait time is quite high.
Advantages
- The simplest form of a CPU scheduling algorithm
- Easy to program
- First come first served
Disadvantages
- It is a Non-Preemptive CPU scheduling algorithm, so after the process has been allocated to the CPU, it will never release the CPU until it finishes executing.
- The Average Waiting Time is high.
- Short processes that are at the back of the queue have to wait for the long process at the front to finish.
- Not an ideal technique for time-sharing systems.
- Because of its simplicity, FCFS is not very efficient.
Algorithm
- Step 1 : Input the number of processes required to be scheduled using FCFS, burst time for each process and its arrival time.
- Step 2 : Using enhanced bubble sort technique, sort the all given processes in ascending order according to arrival time in a ready queue.
- Step 3 : Calculate the Finish Time, Turn Around Time and Waiting Time for each process which in turn help to calculate Average Waiting Time and Average Turn Around Time required by CPU to schedule given set of process using FCFS.
- Step 3.1 : for i = 0 , Finish Time T0 = Arrival Time T0 + Burst Time T0
- Step 3.2 : for i >= 1, Finish Time Ti = Burst Time Ti + Finish Time Ti- 1
- Step 3.3 : for i = 0 , Turn Around Time T0 = Finish Time T0 - Arrival Time T0
- Step 3.4 : for i >= 1, Turn Around Time Ti = Finish Time Ti - Arrival Time Ti
- Step 3.5 : for i = 0 , Waiting Time T0 = Turn Around Time T0 - Burst Time T0
- Step 3.6 : for i >= 1, Waiting Time Ti = Turn Around Time Ti - Burst Time Ti- 1
- Step 4 : Process with less arrival time comes first and gets scheduled first by the CPU.
- Step 5 : Calculate the Average Waiting Time and Average Turn Around Time.
- Step 6 : Stop.