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 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.
- Round Robin Scheduling with different arrival times
- Program for FCFS CPU Scheduling | Set 2 (Processes with different arrival times)
- Program for Priority CPU Scheduling | Set 1
- Program for Preemptive Priority CPU Scheduling
- 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
- Scheduling in Real Time Systems
- Shortest Job First CPU Scheduling with predicted burst time
- Longest Remaining Time First (LRTF) CPU Scheduling Algorithm
- Longest Remaining Time First (LRTF) CPU Scheduling Program
- Difference between Seek Time and Rotational Latency in Disk Scheduling
- Difference between Priority Inversion and Priority Inheritance
- Multilevel Feedback Queue Scheduling (MLFQ) CPU Scheduling