Prerequisite – Program for Round Robin scheduling
Processes are executed on basis of their priority in this scheduling algorithm. Processes have a specific priority associated with them on arrival. When a process arrives its priority is compared with other processes in the ready queue and if its priority is higher then it becomes running process. In case of a non-preemptive algorithm even if the arriving process has a higher priority, running process is not preempted if it is not completely executed i.e., once scheduled process will run till completion.
To avoid starvation of processes which have lower priority, priority of running processes and processes in the ready queue are changed.
Consider a preemptive priority scheduling algorithm where each process arrive at the ready queue with priority zero and priority changed at the rate of α at the ready queue (while waiting) and at the rate of ß at the CPU (while running), then there can be two cases:
- (a) α>ß>0 :
If the rate of increase of priority of processes in ready queue will be more than that of CPU, then after some time, process in ready queue will have a higher priority and hence running process will be preempted and next process with higher priority will be transferred to CPU. It basically becomes Round-robin with dynamic time quantum.
- (b) ß>α>0 :
If the rate of increase of priority of process in ready queue is less than that of running process, then priority of running process will always be higher than process in ready queue. Process is actually similar to First Come First Serve (FCFS) scheduling. As the priority of the running process increases, it has highest priority and hence it keeps on running and if α is too large, then it gets executed until completion.
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.