Each process in the system if given a priority, then the scheduling must be done according to the priority of each process. A higher priority job should get CPU whereas lower priority job can be made to wait. Priority scheduling is necessarily a form of preemptive scheduling where priority is the basic of preemption.
Let us consider a set of processes P1, P2, P3 having priorities ranging from 1 to 3. Let us assume that 1 is the highest priority whereas 3 is the least priority. Let us also assume that p1 arrive first and P3 arrives in the last.
|process||CPU Burst Time||Priority||Arrival|
The Gantt chart is shown below:
Waiting time foe P1= o+ (8-1) =7
Waiting time for P2= 1+ (4-2) =3
Waiting time for P3 = 2
Average Waiting Time = (7+3+2) / 3 = 4 Millisecond
Here, the preemption is based on the priority when P1 execute, P2 arrive with priority 2, which is higher than priority 3 of P1, and thus P1 is preempted. Similarly when P2 execute, P3 arrive with Priority 1 which is the highest priority and thus P2 is preempted and soon.
The main question arise here is if two processes have been assigned same priorities. Priority may be assigned by user or by the operating system depending upon the important of process. In that case comparison will be done with their CPU burst time. The process with short CPU burst time will be executed first.
- Shortest job first scheduling Shortest job first scheduling Key concept of this algorithm is:...
- Shortest Remaining Time Scheduling Shortest remaining time (SRT) scheduling Shortest remaining time scheduling is...
- First Come First Served Algorithm First come first served scheduling algorithm (FCFS) FCFS also termed...
- Round robin scheduling Round Robin Scheduling The basic purpose of this algorithm is...
- Multilevel feedback queues Multilevel feedback Queue scheduling It is an enhancement of multilevel...