1. 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.
2. Round-Robin (RR) :
Round-Robin (RR) Scheduling Algorithm is particularly designed for time sharing systems. The processes are put into the ready queue which is a circular queue in this case. In this case a small unit of time known as time quantum is defined. The algorithm selects the first process from the queue and executes it for the time defined by the time quantum. If the process has burst time less than the time quantum then the CPU executes the next process but if it has burst time higher than the time quantum then the process is interrupted and next process is executed for same time quantum. If a process is interrupted then a context switch happens and the process is put back at the tail of the queue. It is preemptive in nature.
This algorithm mainly depends on the time quantum. Very large time quantum makes RR same as the FCFS while a very small time quantum will lead to the overhead as context switch will happen again and again after very small intervals.
The major advantage of this algorithm is that all processes get executed one after the other which does not lead to starvation of processes or waiting by process for quite long time to get executed.
The difference between Priority Scheduling and Round-Robin (RR) scheduling algorithm are as follows:
|Priority Scheduling||Round-Robin (RR)|
|Priority Scheduling executes the processes according to the priority i.e. process with higher priority is executed first.||Round-Robin (RR) executes the processes based upon the time quantum defined i.e. each process is executed for a fixed amount of time.|
|Priority Scheduling is both preemptive and non-preemptive in nature.||Round-Robin (RR) is preemptive in nature.|
|The average waiting time and average response time is unknown beforehand.||The average waiting time for given set of processes is quite small and depends on the time quantum.|
|It is easy to implement and best suited for real time operating systems.||It is quite easy to implement RR in any system.|
|The problem of blocking of a process can be solved using aging.||Each process is executed and every user feels that his work is being done as the CPU gives equal amount of time to each process.|
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Relation between Preemptive Priority and Round Robin Scheduling Algorithm
- Difference between Preemptive Priority based and Non-preemptive Priority based CPU scheduling algorithms
- Selfish Round Robin CPU Scheduling
- Difference between Priority scheduling and Shortest Job First (SJF) CPU scheduling
- Difference between First Come First Served (FCFS) and Round Robin (RR) Scheduling Algorithm
- Difference between Shortest Job First (SJF) and Round-Robin (RR) scheduling algorithms
- Difference between Longest Job First (LJF) and Round Robin (RR) scheduling algorithms
- Difference between Multi Level Queue (MLQ) Scheduling and Round Robin (RR) algorithms
- Difference between FCFS and Priority CPU scheduling
- Relation in FCFS and Round Robin Scheduling Algorithm
- Program for Round Robin scheduling | Set 1
- Round Robin Scheduling with different arrival times
- Program for Priority CPU Scheduling | Set 1
- Priority CPU Scheduling with different arrival time - Set 2
- Program for Preemptive Priority CPU Scheduling
- CPU Scheduling in Operating Systems using priority queue with gantt chart
- Difference between Multi Level Queue Scheduling (MLQ) and Priority Scheduling
- Difference between Priority Inversion and Priority Inheritance
- Multilevel Feedback Queue Scheduling (MLFQ) CPU Scheduling
- Difference between Turn Around Time (TAT) and Waiting Time (WT) in 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.