Priority scheduling is one of the most common scheduling algorithms in batch systems. Each process is assigned a priority. Process with the highest priority is to be executed first and so on.
Processes with the same priority are executed on first come first served basis. Priority can be decided based on memory requirements, time requirements or any other resource requirement.
1- First input the processes with their burst time and priority. 2- Sort the processes, burst time and priority according to the priority. 3- Now simply apply FCFS algorithm.
Note: A major problem with priority scheduling is indefinite blocking or starvation. A solution to the problem of indefinite blockage of the low-priority process is aging. Aging is a technique of gradually increasing the priority of processes that wait in the system for a long period of time.
Order in which processes gets executed 1 3 2 Processes Burst time Waiting time Turn around time 1 10 0 10 3 8 10 18 2 5 18 23 Average waiting time = 9.33333 Average turn around time = 17
In this post, the processes with arrival time 0 are discussed. In next set, we will be considering different arrival times to evaluate waiting times.
This article is contributed by Sahil Chhabra (akku). If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
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.
- Program for Preemptive Priority CPU Scheduling
- Difference between Multi Level Queue Scheduling (MLQ) and Priority Scheduling
- Difference between Priority Scheduling and Round Robin (RR) CPU scheduling
- Difference between Priority scheduling and Shortest Job First (SJF) CPU scheduling
- Difference between Priority Scheduling and Longest Job First (LJF)
- Difference between FCFS and Priority CPU scheduling
- Fixed-priority pre-emptive scheduling
- Priority CPU Scheduling with different arrival time - Set 2
- Difference between Preemptive Priority based and Non-preemptive Priority based CPU scheduling algorithms
- CPU Scheduling in Operating Systems using priority queue with gantt chart
- Difference between Priority Inversion and Priority Inheritance
- Program for FCFS CPU Scheduling | Set 1
- Program for Shortest Job First (or SJF) CPU Scheduling | Set 1 (Non- preemptive)
- Program for Round Robin scheduling | Set 1
- Program for Shortest Job First (SJF) scheduling | Set 2 (Preemptive)
- Program for SSTF disk scheduling algorithm
- Program for FCFS CPU Scheduling | Set 2 (Processes with different arrival times)
- Longest Remaining Time First (LRTF) CPU Scheduling Program
- Multilevel Feedback Queue Scheduling (MLFQ) CPU Scheduling
- Priority Inversion : What the heck !
Improved By : SHUBHAMSINGH10