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.
- Operating System | Shortest Job First scheduling with predicted burst time
- Scheduling priority tasks in limited time and minimizing loss
- Operating System | Multilevel Queue Scheduling
- Operating System | Process Management | CPU Scheduling
- Operating System | Lottery Process Scheduling
- Operating System | Multiple-Processor Scheduling
- Operating System | Selfish Round Robin Scheduling
- Operating System | Multilevel Feedback Queue Scheduling
- Operating System | Highest Response Ratio Next (HRRN) Scheduling
- Round Robin Scheduling with different arrival times
- Program for FCFS Scheduling | Set 2 (Processes with different arrival times)
- Operating System | Real time systems
- Program for Priority Scheduling | Set 1
- Program for Preemptive Priority CPU Scheduling
- Operating Systems | CPU Scheduling | Question 1
Improved By : Cyberfreak