Prerequisite – Program for Priority Scheduling – Set 1
Priority scheduling is a non-preemptive algorithm and one of the most common scheduling algorithms in batch systems. Each process is assigned first arrival time (less arrival time process first) if two processes have same arrival time, then compare to priorities (highest process first). Also, if two processes have same priority then compare to process number (less process number first). This process is repeated while all process get executed.
- First input the processes with their arrival time, burst time and priority.
- Sort the processes, according to arrival time if two process arrival time is same then sort according process priority if two process priority are same then sort according to process number.
- Now simply apply FCFS algorithm.
Gantt Chart –
Input : process no-> 1 2 3 4 5 arrival time-> 0 1 3 2 4 burst time-> 3 6 1 2 4 priority-> 3 4 9 7 8 Output : Process_no Start_time Complete_time Trun_Around_Time Wating_Time 1 0 3 3 0 2 3 9 8 2 4 9 11 9 7 3 11 12 9 8 5 12 16 12 8 Average Wating Time is : 5.0 Average Trun Around time is : 8.2
Process_no Start_time Complete_time Trun_Around_Time Wating_Time 1 1 4 3 0 2 4 9 7 2 3 9 10 7 6 4 10 17 13 6 5 17 21 16 12 Average Wating Time is : 5.2 Average Trun Around time is : 9.2
This article is contributed by Amit Verma . 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 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.
- Difference between Arrival Time and Burst Time in CPU Scheduling
- Difference between Multi Level Queue Scheduling (MLQ) and Priority Scheduling
- Difference between Priority Scheduling and Round Robin (RR) CPU scheduling
- Round Robin Scheduling with different arrival times
- Difference between Priority scheduling and Shortest Job First (SJF) CPU scheduling
- Program for FCFS CPU Scheduling | Set 2 (Processes with different arrival times)
- Program for Priority CPU Scheduling | Set 1
- Difference between FCFS and Priority CPU scheduling
- Difference between Priority Scheduling and Longest Job First (LJF)
- Program for Preemptive Priority CPU Scheduling
- Fixed-priority pre-emptive scheduling
- 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 Seek Time and Transfer Time in Disk Scheduling
- Least Slack Time (LST) scheduling Algorithm in real-time systems
- Difference between Turn Around Time (TAT) and Waiting Time (WT) in CPU Scheduling
- Difference between Seek Time and Disk Access Time in Disk Scheduling
- Difference between Transfer Time and Disk Access Time in Disk Scheduling
- Scheduling in Real Time Systems
- Shortest Job First CPU Scheduling with predicted burst time