1. First Come First Served (FCFS) :
First Come First Served (FCFS) is the simplest type of algorithm. It is a non-preemptive algorithm i.e. the process cannot be interrupted once it starts executing. The FCFS is implemented with the help of a FIFO queue. The processes are put into the ready queue in the order of their arrival time. The process that arrives first becomes the head of the queue while the others that arrive after are added to the rear of the queue. In First Come First Served (FCFS) algorithm, the process that arrives first, is sent first for execution by the CPU when CPU is free.
The main disadvantage of this algorithm is that the average waiting time is often quite long. It also leads to the convoy effect. This results in lower device or CPU utilisation and lower efficiency.
2. Priority Scheduling Algorithm:
Priority scheduling algorithm executes the processes depending upon their priority. Each process is allocated a priority and the process with the highest priority is executed first. Priorities can be defined internally as well as externally. Internal priorities are decided by the system depending upon the number of resources required, time needed etc. whereas external priorities are based upon the time in which the work is needed or the amount being paid for the work done or the importance of process. Priority scheduling can be preemptive or non- preemptive.
- If two processes have the same priority then tie is broken using FCFS.
- The waiting time for the highest priority process is always zero in preemptive mode while it may not be zero in case of non preemptive mode.
The major problem is the starvation or indefinite blocking. It may so happen that in stream of processes, the system keeps executing the high priority processes and the low priority processes never get executed.
A solution to the problem is aging. Aging refers to gradually increasing the priority of processes waiting in the system by a fixed number after a fixed interval, say by 1 in every 10 minutes. This will ensure that a low priority process also gets executed by slowly increasing its priority with the time.
Differences between FCFS and Priority scheduling algorithm :
|First Come First Served (FCFS)||Priority scheduling|
|It executes the processes in the order in which they arrive i.e., the process that arrives first is executed first.||It executes the processes based upon their prioritied i.e., in descending order of their priorities. A process with higher priority is executed first.|
|It is non preemptive in nature.||It is both non-preemptive and preemptive in nature.|
|It results in quite long waiting time for the processes and thus increases average waiting time.||There is no idea of response time and waiting time.|
|It leads to the convoy effect.||It may happen that a low priority process keeps waiting for an indefinite time and never gets executed.|
|It is the easiest to implement in any system.||It is best suited for real time operating systems.|
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Difference between Multi Level Queue Scheduling (MLQ) and Priority Scheduling
- Difference between Priority Scheduling and Round Robin (RR) CPU scheduling
- Difference between FCFS and SJF CPU scheduling algorithms
- Difference between Priority scheduling and Shortest Job First (SJF) CPU scheduling
- Difference between FCFS and C-LOOK disk scheduling algorithm
- Difference between FCFS and SCAN disk scheduling algorithms
- Difference between FCFS and SSTF Disk Scheduling Algorithm
- Difference between First Come First Served (FCFS) and Longest Job First (LJF) CPU scheduling algorithms
- Difference between First Come First Served (FCFS) and Round Robin (RR) Scheduling Algorithm
- Difference between Multi Level Queue Scheduling (MLQ) and First Come First Served (FCFS)
- Difference between Priority Scheduling and Longest Job First (LJF)
- Difference between Preemptive Priority based and Non-preemptive Priority based CPU scheduling algorithms
- Program for FCFS CPU Scheduling | Set 1
- FCFS Disk Scheduling Algorithms
- FCFS Scheduling Full Form
- Program for FCFS CPU Scheduling | Set 2 (Processes with different arrival times)
- Program for Priority CPU Scheduling | Set 1
- Fixed-priority pre-emptive scheduling
- Priority CPU Scheduling with different arrival time - Set 2
- Program for Preemptive Priority CPU Scheduling
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.