First Come, First Served (FCFS)
First Come, First Served (FCFS) is a scheduling algorithm used in computer operating systems and other applications. This scheduling algorithm follows a simple rule: the task that arrives first is executed first. The first-come, first-served algorithm is also known as the first-in, first-out (FIFO) algorithm.
In the FCFS scheduling algorithm, the operating system allocates the CPU (central processing unit) to the first task that requests it. The CPU remains allocated to that task until it finishes its processing or goes into the waiting state, where it has to wait for some event to occur.
FCFS is a non-preemptive scheduling algorithm, which means that once a task acquires the CPU, it continues to use it until it completes its execution or gets blocked due to some reason. In other words, the CPU of the system is assigned to a process, and it remains assigned to that process until the process terminates, or the process enters the waiting state.
In this type of scheduling, processes are scheduled according to the order in which they arrive in the ready queue. The ready queue is a waiting area where processes are loaded while they wait for their turn to execute on the CPU. The FCFS algorithm works based on the principle of first-come, first-served, so the process that first arrived in the queue gets executed first, and the other processes have to wait until the earlier ones complete.
When the CPU is idle, the first process in the queue is selected and moved into the running state. The operating system then assigns resources to it so that it can execute its instructions. In case the process needs to wait for any input/output (I/O) operation or any other event, it goes into the waiting state. The ready queue then selects the next process in the queue.
One disadvantage of the FCFS scheduling algorithm is that it can lead to a problem known as the “convoy effect.” This effect occurs when a process with a long execution time, known as a CPU-bound process, takes up the CPU, and other processes have to wait, which can hurt performance.
In summary, the FCFS algorithm assigns the CPU to a process that’s first in line, and it remains with that process until it completes or goes into the waiting state. However, this algorithm is not as efficient as some alternatives since it can lead to a convoy effect and can cause delays of all other jobs, especially CPU-bound jobs.