OS | FCFS vs SJF | Exp - 5


FCFS vs SJF Scheduling

1. First Come First Serve Scheduling

In the "First come first serve" scheduling algorithm, as the name suggests, the process which arrives first, gets executed first, or we can say that the process which requests the CPU first, gets the CPU allocated first.
  • First Come First Serve, is just like FIFO(First in First out) Queue data structure, where the data element which is added to the queue first, is the one who leaves the queue first.
  • This is used in Batch Systems.
  • It's easy to understand and implement programmatically, using a Queue data structure, where a new process enters through the tail of the queue, and the scheduler selects process from the head of the queue.
  • A perfect real life example of FCFS scheduling is buying tickets at ticket counter.
For more info visit Study Tonight

2. Short Job First Scheduling in OS

Shortest job first (SJF) or shortest job next, is a scheduling policy that selects the waiting process with the smallest execution time to execute next. SJN is a non-preemptive algorithm.
  • Shortest Job first has the advantage of having minimum average waiting time among all scheduling algorithms.
  • It is a Greedy Algorithm.
  • It may cause starvation if shorter processes keep coming. This problem can be solved using the concept of ageing.
  • It is practically infeasible as Operating System may not know burst time and therefore may not sort them. While it is not possible to predict execution time, several methods can be used to estimate the execution time for a job, such as a weighted average of previous execution times. SJF can be used in specialized environments where accurate estimates of running time are available.
Algorithm:
  1. Sort all the processes in increasing order according to burst time.
  2. Then simply, apply FCFS.

For more info visit GeeksforGeeks

Problem Statement

If there are four students want to access a photocopy machine. The arrival time and access time for each students are as follows-Compute the Waiting time through the FCFS and SJF Algorithms and find which is better.

No comments:

Powered by Blogger.