Priority Based Process Scheduling in operating systems

Priority Based Process Scheduling:

Priority scheduling is a non-preemptive algorithm so processes priority matters.

Each process has a priority number.

Process with high priority always gets the CPU on a priority basis.

Processes with the same priority are executed according to the first come first served(FCFS)scheduling algorithm.

Preferred in batch systems.

Process Burst Time Priority
P1 4 2nd
P2 2 3rd
P3 8 1st
P4 3 4th

 

P3 P1 P2 P4
0                              8                             12                              14                     17

 

Process Waiting Time
P1 8
P2 12
P3 0
P4 14

Average Wait Time: (0+8+12+14) / 4 = 8.5

Priority Based Process Scheduling Program in C++ (C Plus Plus)