Understanding FCFS Scheduling Algorithms in Operating Systems (OS) with Examples

FCFS (First-Come-First-Serve) scheduling algorithm is one of the basic scheduling algorithms used in operating systems. It is a non-pre-emptive scheduling algorithm that schedules the processes in the order in which they arrive in the ready queue. In this article, we will discuss the FCFS scheduling algorithm in detail, its advantages and disadvantages, and provide examples to illustrate how it works.
Understanding FCFS Scheduling Algorithms in Operating Systems with Examples.png

Free Learning source for Operating System at "Computer Courses - All in One" Android App

How does FCFS scheduling algorithm work? 

In the FCFS scheduling algorithm, the process that arrives first gets executed first. Once the CPU starts executing a process, it continues to do so until the process completes its execution or blocks for some input/output operation. The next process in the ready queue is then selected for execution.
Let's take an example to understand this better. Consider the following set of processes with their arrival times and burst times:

Calculate Average Waiting time and Average TAT Using FCFS algorithm for given schedule:

Calculate Average Waiting time and Average TAT Using FCFS algorithm for
given schedule:
The FCFS scheduling algorithm will schedule these processes in the order in which they arrive. The Gantt chart for these processes would look like this:
Calculate Average Waiting time and Average TAT Using FCFS algorithm for
given schedule:
As we can see, process P1 arrives at time 0 and is executed first. It completes its execution at time 4. Then, the process P2 arrives at time 2 and is executed next. Similarly, the processes P3 and P4 arrive at times 3 and 5, respectively, and are executed in the order in which they arrive. 
Solution:
Job Arrival Time Burst Time Finish Time Turnaround Time Waiting Time
P1 0 4 4 4 0
P2 2 3 7 5 2
P3 3 2 9 6 4
P4 5 1 10 5 4
Average 20 / 4 = 5 10 / 4 = 2.5

Free Learning source for Operating System at "Computer Courses - All in One" Android App

Advantages of FCFS scheduling algorithm 
The FCFS scheduling algorithm is easy to understand and implement. It ensures that the processes are executed in the order in which they arrive, which is fair to all the processes. This scheduling algorithm also avoids starvation, as no process will be left waiting indefinitely for CPU time.
Disadvantages of FCFS scheduling algorithm 
 The FCFS scheduling algorithm has some drawbacks. One of the main disadvantages is that it is not suitable for a system with a mix of short and long processes. In such a system, the short processes may have to wait for a long time before they can get CPU time, which can result in poor performance. Additionally, the FCFS scheduling algorithm does not consider the priority of the processes. Therefore, if a high-priority process arrives after a low-priority process, it may have to wait for a long time before it can get CPU time.

Free learning Android app "Operating System - All In One"

Conclusion 
In conclusion, the FCFS scheduling algorithm is one of the basic scheduling algorithms used in operating systems. It schedules the processes in the order in which they arrive in the ready queue, which is fair to all the processes. However, it has some drawbacks, such as poor performance in a system with a mix of short and long processes, and not taking into account the priority of the processes. Therefore, in practice, other scheduling algorithms such as SJF (Shortest-Job-First) and Priority Scheduling are often used to achieve better performance. I hope this article has helped you understand the FCFS scheduling algorithm in OS. If you have any questions or feedback, please feel free to leave a comment below.

Post a Comment

0 Comments