# FCFS: First Come First Serve Scheduling Algorithm

This article is about one of the **Scheduling Algorithms in Operating System**. In this article we are going to study about the **FCFS**, i.e. **First Come First Serve Scheduling Algorithm**. We will first define it briefly and will then also illustrate it with the help of an example.

Submitted by Monika Sharma, on June 22, 2019

The **FCFS**, which stands for **First Come First Serve Scheduling Algorithm**, is a non-preemptive scheduling algorithm, which means that if a process once starts executing in the processor, then it cannot be preempted in between the processing. Thus, the concept of priority and urgency is not implemented by this type of algorithm. In the FCFS algorithm, the process gets executed in the same sequence in which they enter the Ready state. It simply follows the strategy of **"First come First serve with special services provided to none."**

Now let us try to understand this further with the help of an example. Suppose there are four processes with process ID's **P1**, **P2**, **P3**, and **P4** and they enter into the CPU as follows:

Process ID | Arrival Time (milliseconds) |
Burst Time (milliseconds) |
---|---|---|

P1 | 0 | 5 |

P2 | 2 | 3 |

P3 | 6 | 2 |

P4 | 7 | 3 |

So, if the OS follows the **FCFS algorithm** for scheduling these processes, then they will be executed in the following manner:

**Gant Chart:**

Total Turn around Time = 5 + 6 + 4 + 6 = 21 milliseconds Average Turn Around Time= Total Turn Around Time / Total No. of Processes = 21 / 4 = 5.25 milliseconds Total Waiting Time = 0 + 3 + 2 + 3 = 8 milliseconds Average Waiting Time = Total Waiting Time / Total No. of Processes = 8 / 4 = 2 milliseconds

TOP Interview Coding Problems/Challenges

- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path

Comments and Discussions