Prerequisite – CPU Scheduling in Operating Systems
Fixed priority pre-emptive scheduling algorithm is mostly used in real time systems.
In this scheduling algorithm the processor make sure that the highest priority task is to be performed first ignoring the other task to be executed.
The process having highest priority is served first.
Pre-emptive: When a process arrives its priority is compared with the current process’s priority.If the new job have higher priority then the current process, the current process is suspended and new process is started.
Sorted FIFO queue is used for this strategy. As the new process is identified it is placed in the queue according to it’s priority.Hence the process having higher priority is considered first as it is placed at higher position.
Let us take the following example having 4 set of processes along with its arrival time and time taken to complete the process.Also the priority of all the process are mentioned.Consider all time values in millisecond and small value of priority means higher priority of process.
|Process||Arrival Time(T0)||Time Required for Completion(T`)||Priority|
Initially only P0 is present and it is allowed to run.But when P1 comes, it has higher priority.So, P0 is pre-empted and P1 is allowed to run.This process repeated till all processes complete their execution.
|Process||Arrival Time(T0)||Completion time(T`)||Finish Time(T1)||TurnAround time(TAT=T1-T0)||Waiting time(TAT-T`)|
Average Turnaround time:
= (22+12+2+4) / 4 = 40 / 4 = 10 ms
Average Waiting time:
= (12+6+0+0) / 4 = 18 / 4 = 4.5 ms
Priority is considered.Critical process can get even better response.
Starvation is possible for low priority process.It can be overcome by using technique called “Aging“. Aging gradually increases the priority of the process that wait in the system for long time. Context switch overhead is there.
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.
- Difference between Preemptive Priority based and Non-preemptive Priority based CPU scheduling algorithms
- Difference between Preemptive and Non-preemptive CPU scheduling algorithms
- Preemptive and Non-Preemptive Scheduling
- Program for Shortest Job First (or SJF) CPU Scheduling | Set 1 (Non- preemptive)
- Program for Shortest Job First (SJF) scheduling | Set 2 (Preemptive)
- Program for Preemptive Priority CPU Scheduling
- First Come, First Serve – CPU Scheduling | (Non-preemptive)
- Shortest Job First (or SJF) CPU Scheduling Non-preemptive algorithm using Segment Tree
- Relation in FCFS and Preemptive Priority Scheduling Algorithm
- Relation between Preemptive Priority and Round Robin Scheduling Algorithm
- Multilevel Feedback Queue Scheduling (MLFQ) CPU Scheduling
- Difference between Priority Scheduling and Round Robin (RR) CPU scheduling
- Difference between Priority scheduling and Shortest Job First (SJF) CPU scheduling
- Difference between Multi Level Queue Scheduling (MLQ) and Priority Scheduling
- Implementation of Non-Preemptive Shortest Job First using Priority Queue
- Difference between Preemptive and Cooperative Multitasking
- Program for FCFS CPU Scheduling | Set 1
- Program for Round Robin scheduling | Set 1
- CPU Scheduling in Operating Systems
- Disk Scheduling Algorithms
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.