Priority Based Scheduling Algorithm in Operating system

Priority Based Scheduling Algorithm in Operating system

A set of processes where every process has a specific priority with respect to other process.

Types of Priority scheduling is Fixed and Dynamic Priority Scheduling.

In Fixed, process is assigned a fixed priority at the start.

In Dynamic during execution the priority is calculated and assigned to process.

  • Every procedure is given a priority. The process with the highest priority is given the CPU.
  • Two processes are scheduled in FCFS order if their priorities are equivalent.
  • The priority is often represented by a number between 0 and 7 or 0 and 4095. Here, we take the position that 0 denotes a high priority.
  • Time constraints, memory requirements, the number of open files, and the ratio of the average I/O burst to the average CPU burst can all be used to determine the priority.
  • It can be either preemptive or nonpreemptive.
  • When using a preemptive priority scheduling technique, the CPU will only be preempted if a newly arrived process has a higher priority than a process that is already running.
  • Whenever a nonpreemptive priority scheduling technique is used, the newly arrived process will be prioritized and moved to the front of the ready queue.
  • The main drawback of this scheduling algorithm is indefinite blocking or starvation (this algorithm can leave the low priority processes waiting indefinitely).
  • One of the most popular scheduling methods in batch systems is priority scheduling, a non-preemptive technique.

A priority is given to each procedure. The highest priority process should be carried out first, and so on.

  • Processes of the same priority are carried out in the order they are received.
  • Based on memory needs, time needs, or any other resource needs, priority can be determined.

Given: Table of processes their Arrival time, Execution time and priority. Here we are considering 1 is the lowest priority.

Process Arrival Time Execution Time Priority Service Time
P0 0 5 1 0
P1 1 3 2 11
P2 2 8 1 14
P3 3 6 3 5

Waiting time of each process:

Process Waiting Time
P0 0 – 0 = 0
P1 11 – 1 = 10
P2 14 – 2 = 12
P3 5 – 3 = 2

Average Wait Time: (0 + 10 + 12 + 2)/4 = 24 / 4 = 6

Example:

Process CPU-Burst Time Priority
P1 11 3
P2 2 1
P3 3 4
P4 1 5
P5 5 2

Search within CuiTutorial

Scroll to Top