What Does First Come, First Served Mean?
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 (AI) 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 job scheduling algorithm.
Techopedia Explains First Come, First Served
FCFS is an easy-to-setup and implement algorithm that does not prioritize tasks and requests by estimating how much time it will take to complete a task. While this allows it to be efficient and quick in systems that handle multiple tasks of similar nature that demand near-identical time and computational power, it does not perform as well when it comes to complex systems that need to handle a wide variety of requests at the same time.
Use of the FCFS algorithm risks the possibility that a series of simple requests will get stuck in a central processing unit's queue for an unreasonably long wait time behind a single complex task — just because the complex task arrived first.
How a FCFS Scheduling Algorithm Works
Here is how an FCFS scheduling algorithm works. To begin, suppose there are three requests to process in the CPU’s queue: P1, P2, and P3. Assume P1 is a complex process that requires approximately 25 seconds, P2 a much simpler request that requires only 10 seconds of processing, and P3 a moderately simple request that requires 15 seconds.
When P1 is first put in the queue, the wait time is zero and the CPU starts the processing immediately. P2, on the other hand, would have a wait time of 25 seconds. And P3, having arrived last, would have to wait 35 seconds. As a total, an FCFS scheduling algorithm would need 50 seconds to complete all three requests and empty the queue, which would be the same as other sequential processing, mono-CPU systems.
Because FCFS does not evaluate requests before starting, it has fewer complete tasks per set period of time when compared to an intelligent scheduling algorithm. In this scenario, the FCFS scheduling algorithm would complete a single task in the first half of its run time of 25 seconds. Other algorithms—that start from the simplest of requests, for example—would have finished two requests.
The Convoy Effect and FCFS
The scenario aforementioned is an example of the Convoy Effect in operating systems. In this context, the word ‘Convoy’ refers to a real-world situation in which a group of vehicles travel together and one unit. If one vehicle in the convoy gets stuck behind a much slower vehicle, the result is that the rest of the convoy will slow down. (Note: This analogy is only true in sequential processing when there is not an alternative processing unit to take a part of the load off of the primary processing unit.)
Despite the various downsides of using an FCFS scheduling algorithm, it has many use cases where intelligent scheduling algorithms end up wasting more time re-evaluating the priority of each request after it finishes processing the previous one.