Open In App

Fixed-priority pre-emptive scheduling

Last Updated : 16 Apr, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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.

Decision Mode:
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.

Implementation:
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.

Example:
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
P0 0 10 5
P1 1 6 4
P2 3 2 2
P3 5 4 0

Gantt chart:

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.

Statistic :

Process Arrival Time(T0) Completion time(T`) Finish Time(T1) TurnAround time(TAT=T1-T0) Waiting time(TAT-T`)
P0 0 10 22 22 12
P1 1 6 13 12 6
P2 3 2 5 2 0
P3 5 4 9 4 0

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 

Advantages:
Priority is considered.Critical process can get even better response.

Disadvantage:
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.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads