FCFS CPU Scheduling | Operating System - Computer Science Engineering (CSE) PDF Download

Program for FCFS CPU Scheduling

Given n processes with their burst times, the task is to find average waiting time and average turn around time using FCFS scheduling algorithm.
First in, first out (FIFO), also known as first come, first served (FCFS), is the simplest scheduling algorithm. FIFO simply queues processes in the order that they arrive in the ready queue.
In this, the process that comes first will be executed first and next process starts only after the previous gets fully executed.
Here we are considering that arrival time for all processes is 0.

How to compute below times in Round Robin using a program? 

  1. Completion Time: Time at which process completes its execution.
  2. Turn Around Time: Time Difference between completion time and arrival time. Turn Around Time = Completion Time – Arrival Time
  3. Waiting Time(W.T): Time Difference between turn around time and burst time.
    Waiting Time = Turn Around Time – Burst Time

In this post, we have assumed arrival times as 0, so turn around and completion times are same.

FCFS CPU Scheduling | Operating System - Computer Science Engineering (CSE)

Implementation

  1. Input the processes along with their burst time (bt).
  2. Find waiting time (wt) for all processes.
  3. As first process that comes need not to wait so waiting time for process 1 will be 0 i.e. wt[0] = 0.
  4. Find waiting time for all other processes i.e. for process i -> wt[i] = bt[i - 1] + wt[i - 1] .
  5. Find turnaround time = waiting_time + burst_time for all processes.
  6. Find average waiting time = total_waiting_time / no_of_processes.
  7. Similarly, find average turnaround time = total_turn_around_time / no_of_processes.

Processes with different arrival times

Given n processes with their burst times and arrival times, the task is to find average waiting time and average turn around time using FCFS scheduling algorithm.
FIFO simply queues processes in the order they arrive in the ready queue. Here, the process that comes first will be executed first and next process will start only after the previous gets fully executed. 

  1. Completion Time: Time at which process completes its execution.
  2. Turn Around Time: Time Difference between completion time and arrival time. Turn Around Time = Completion Time – Arrival Time
  3. Waiting Time(W.T): Time Difference between turn around time and burst time. Waiting Time = Turn Around Time – Burst Time.

FCFS CPU Scheduling | Operating System - Computer Science Engineering (CSE)

FCFS CPU Scheduling | Operating System - Computer Science Engineering (CSE)

FCFS CPU Scheduling | Operating System - Computer Science Engineering (CSE)

Service Time: Service time means amount of time after which a process can start execution. It is summation of burst time of previous processes (Processes that came before)

Changes in code as compare to code of FCFS with same arrival time: 
To find waiting time: Time taken by all processes before the current process to be started
(i.e. burst time of all previous processes) – arrival time of current process
wait_time[i] = (bt[0] + bt[1] +…… bt[i - 1] ) – arrival_time[i]

Implementation

  1. Input the processes along with their burst time(bt) and arrival time(at)
  2. 2- Find waiting time for all other processes i.e. for a given process  i: wt[i] = (bt[0] + bt[1] +...... bt[i - 1]) - at[i] 
  3. Now find turn around time = waiting_time + burst_time for all processes
  4. Average waiting time = total_waiting_time / no_of_processes
  5. Average turn around time = total_turn_around_time / no_of_processes

Convoy Effect in Operating Systems

Convoy Effect is phenomenon associated with the First Come First Serve (FCFS) algorithm, in which the whole Operating System slows down due to few slow processes.

The Convey Effect, VisualizedThe Convey Effect, Visualized

FCFS algorithm is non-preemptive in nature, that is, once CPU time has been allocated to a process, other processes can get CPU time only after the current process has finished. This property of FCFS scheduling leads to the situation called Convoy Effect.
Suppose there is one CPU intensive (large burst time) process in the ready queue, and several other processes with relatively less burst times but are Input/Output (I/O) bound (Need I/O operations frequently).

Steps are as following below:

  • The I/O bound processes are first allocated CPU time. As they are less CPU intensive, they quickly get executed and goto I/O queues.
  • Now, the CPU intensive process is allocated CPU time. As its burst time is high, it takes time to complete.
  • While the CPU intensive process is being executed, the I/O bound processes complete their I/O operations and are moved back to ready queue.
  • However, the I/O bound processes are made to wait as the CPU intensive process still hasn’t finished. This leads to I/O devices being idle.
  • When the CPU intensive process gets over, it is sent to the I/O queue so that it can access an I/O device.
  • Meanwhile, the I/O bound processes get their required CPU time and move back to I/O queue.
  • However, they are made to wait because the CPU intensive process is still accessing an I/O device. As a result, the CPU is sitting idle now.

Hence in Convoy Effect, one slow process slows down the performance of the entire set of processes, and leads to wastage of CPU time and other devices.
To avoid Convoy Effect, preemptive scheduling algorithms like Round Robin Scheduling can be used – as the smaller processes don’t have to wait much for CPU time – making their execution faster and leading to less resources sitting idle.

The document FCFS CPU Scheduling | Operating System - Computer Science Engineering (CSE) is a part of the Computer Science Engineering (CSE) Course Operating System.
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)
10 videos|99 docs|33 tests

Top Courses for Computer Science Engineering (CSE)

FAQs on FCFS CPU Scheduling - Operating System - Computer Science Engineering (CSE)

1. What is FCFS CPU Scheduling?
Ans. FCFS (First-Come-First-Serve) CPU Scheduling is a scheduling algorithm used by operating systems to determine the order in which processes are executed by the CPU. In this algorithm, the process that arrives first is executed first, without considering its burst time or priority.
2. How does FCFS CPU Scheduling work?
Ans. FCFS CPU Scheduling works by assigning the CPU to the process that arrives first and keeps it until it completes its execution. When a process arrives, it is added to the end of the ready queue. The CPU then executes the process in the front of the queue until it finishes, and then moves on to the next process in the queue.
3. What are the advantages of FCFS CPU Scheduling?
Ans. The advantages of FCFS CPU Scheduling include simplicity, as it is easy to implement and understand. It also provides fairness, as each process gets a chance to run in the order of their arrival. Additionally, it is non-preemptive, meaning once a process starts executing, it cannot be interrupted until it completes.
4. What are the limitations of FCFS CPU Scheduling?
Ans. FCFS CPU Scheduling has some limitations. One major limitation is the lack of consideration for the burst time of processes. This can lead to poor average waiting time and turnaround time, especially if long processes arrive before shorter ones. Additionally, FCFS suffers from the "convoy effect," where a long process can hold up the execution of subsequent short processes.
5. When is FCFS CPU Scheduling suitable to use?
Ans. FCFS CPU Scheduling is suitable to use in scenarios where the burst time of processes is similar or when the execution order does not significantly impact the overall performance. It can be useful in batch processing or when fairness is a priority. However, in scenarios with varying burst times or when responsiveness is crucial, other scheduling algorithms like Round Robin or Shortest Job Next may be more appropriate.
10 videos|99 docs|33 tests
Download as PDF
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

past year papers

,

Objective type Questions

,

Exam

,

mock tests for examination

,

study material

,

Extra Questions

,

Summary

,

Important questions

,

ppt

,

practice quizzes

,

pdf

,

FCFS CPU Scheduling | Operating System - Computer Science Engineering (CSE)

,

Sample Paper

,

Previous Year Questions with Solutions

,

shortcuts and tricks

,

Viva Questions

,

video lectures

,

FCFS CPU Scheduling | Operating System - Computer Science Engineering (CSE)

,

FCFS CPU Scheduling | Operating System - Computer Science Engineering (CSE)

,

Free

,

Semester Notes

,

MCQs

;