Simran 41721016 OS Program 2
Simran 41721016 OS Program 2
AIM: Write a program to implement First Come First Service CPU Scheduling
Policy.
The First-Come, First-Served (FCFS) CPU scheduling policy is one of the simplest and most
intuitive algorithms used in operating systems for managing the execution of processes. In
the FCFS scheduling policy, processes are executed in the order they arrive in the ready
queue, with the first process to arrive being the first one to execute, hence the name "First-
Come, first Served." This policy is based on the principle of fairness, as it ensures that every
process gets a chance to run in the order, they request CPU time. While FCFS has its
advantages, it also has limitations that make it less suitable for certain scenarios.
FCFS maintains a simple FIFO (First-In-First-Out) queue to order the execution of processes.
As processes arrive in the ready state, they are added to the end of the queue. When the
CPU becomes available, the process at the front of the queue is selected for execution. FCFS
is a non preamptive scheduling algorithm, meaning that once a process starts executing, it
continues to run until it completes or voluntarily yields the CPU. No other process can
preempt its execution.
Advantages:
• FCFS ensures fairness by executing processes in the order they request CPU time.
This property makes it suitable for scenarios where equal access to the CPU is
essential.
• It is suitable for systems with limited computational resources or where simplicity is
preferred.
Disadvantages:
• FCFS is susceptible to the "convoy effect," where a long-running process can hold up
the execution of subsequent processes. Shorter processes may be delayed
significantly if a long process arrives first, leading to inefficient CPU utilization.
• FCFS does not consider the relative execution times or priority of processes. This can
lead to inefficient CPU usage when shorter processes must wait for longer ones to
complete.
• FCFS does not account for the priority of processes. Critical or time-sensitive
processes may be delayed if lower-priority processes are executing.
• FCFS is not suitable for real-time systems or scenarios where strict deadlines must be
met because it lacks mechanisms to prioritize time-sensitive tasks.
Code for Implementation:
Output:
Conclusion: First Come First Service Scheduling Policy has been implemented through the
program and the output is shown as per requirements.