Priority Scheduling in OS
Priority scheduling is a CPU scheduling algorithm in OS, where
- Each process is assigned a priority
- The CPU scheduler always selects the process with the highest priority in the ready queue.
Note: In most systems, a lower priority number indicates a higher priority (for example, Priority 1 is higher than Priority 3), though some operating systems use the opposite convention.
Types of Priority Scheduling
There are two types of priority scheduling in OS

In non-preemptive scheduling, once a process gets the CPU, it continues until it completes. All new incoming processes must wait for the currently executing process to terminate.
In preemptive scheduling, once a process gets the CPU, it may be interrupted by the arrival of a higher-priority process. The higher-priority process immediately gets the CPU.
How Priority Scheduling Works
The working steps of Priority Scheduling are:
- All processes enter the ready queue according to their arrival time.
- Each process is assigned a priority.
- The scheduler selects the process with the highest priority.
- If two processes have the same priority, FCFS (First-Come, First-Served) is used to break the tie.
- The selected process executes until it completes (Non-Preemptive) or until a higher-priority process arrives (Preemptive).
- The process repeats until all processes have completed.
Non-Preemptive Priority Scheduling Example
Consider the following relation, which includes the Process ID, Arrival time, and burst time.

Gannt. Chart of the preemptive priority scheduling example is given below, which shows the process when
- it gets the CPU for the first time
- and completes its execution

Let’s calculate when a process gets the CPU for the first time, Completion Time (CT), Waiting Time (WT), Turnaround Time (TAT), Average Waiting Time (AWT), Average Turnaround Time (ATAT), and Response Time (RT) of the given non-preemptive Example
Process ID is set according to Priority to solve the example

Preemptive Priority Scheduling Example
Consider the following relation, which includes the Process ID, Arrival time, and burst time.

Let’s calculate when a process gets the CPU for the first time, Completion Time (CT), Waiting Time (WT), Turnaround Time (TAT), Average Waiting Time (AWT), Average Turnaround Time (ATAT), and Response Time (RT) of a preemptive priority scheduling given example

Let’s calculate when a process gets the CPU for the first time, Completion Time (CT), Waiting Time (WT), Turnaround Time (TAT), Average Waiting Time (AWT), Average Turnaround Time (ATAT), and Response Time (RT) of preemptive priority scheduling given an example

Characteristics of Priority Scheduling in OS
Here are the main characteristics of Priority Scheduling in OS
- Priority-Based Execution: The CPU selects the process with the highest priority from the ready queue.
- Priority Assignment: Priorities can be assigned statically (fixed before execution) or dynamically (changed during execution).
- Preemptive or Non-Preemptive: It can work in both modes. In the preemptive version, a higher-priority process interrupts the currently running process. In the non-preemptive version, the running process finishes before another process starts.
- Supports Important Tasks: High-priority processes receive CPU time before lower-priority processes, making it suitable for critical applications.
- Starvation May Occur: Low-priority processes may wait for a long time if higher-priority processes keep arriving.
- Ageing Can Prevent Starvation: The priority of waiting processes can be increased over time to ensure they eventually get CPU time.
- Tie Breaking: If two processes have the same priority, the CPU usually schedules them using First-Come, First-Served (FCFS).
- Flexible Scheduling: Different priority levels allow the operating system to manage system, interactive, and background processes efficiently.
- Suitable for Real-Time Systems: It is commonly used in systems where important tasks must be completed as quickly as possible.
- Simple to Implement: The algorithm is straightforward when priorities are predefined and managed properly.
Advantages of Priority Scheduling
Here are the key advantages of priority scheduling in OS
- Fast Execution of Important Processes: High-priority processes are executed first, reducing their waiting time.
- Flexible Scheduling: Process priorities can be adjusted dynamically to meet system requirements.
- Suitable for Real-Time Systems: It is ideal for real-time and critical applications where urgent tasks must run first.
- Better Response Time: High-priority tasks receive CPU time quickly, improving system responsiveness.
- Efficient CPU Utilisation: Important processes are completed sooner, helping the system perform more efficiently.
Disadvantages of Priority Scheduling
Here are the main disadvantages of priority scheduling in OS
- Starvation: Low-priority processes may wait indefinitely if high-priority processes keep arriving.
- Difficult Priority Assignment: Choosing appropriate priority values for processes can be challenging.
- More Context Switching: In the preemptive version, frequent interruptions increase context-switching overhead.
- Less Fair: Lower-priority processes may receive very little CPU time compared with higher-priority ones.
- Aging May Be Required: Additional techniques, such as ageing, are needed to prevent starvation.
When to Use Priority Scheduling
Use Priority Scheduling when:
- Some processes are more important than others.
- Critical or emergency tasks require immediate CPU access.
- Real-time systems require fast execution of high-priority processes.
- System performance depends on completing important tasks first.
- The operating system must give preference to system- or time-sensitive processes.
FAQs of Priority Scheduling in OS
1. What is Priority Scheduling in OS?
Priority Scheduling is a CPU scheduling algorithm that executes the process with the highest priority before lower-priority processes.
2. What are the types of Priority Scheduling?
There are two types:
- Preemptive Priority Scheduling
- Non-Preemptive Priority Scheduling
3. What is starvation in Priority Scheduling?
Starvation occurs when low-priority processes wait indefinitely because higher-priority processes keep getting the CPU.
4. How can starvation be prevented?
Starvation is prevented using ageing, which gradually increases the priority of waiting processes.
5. Is Priority Scheduling preemptive or non-preemptive?
It can be implemented as either preemptive or non-preemptive, depending on the operating system.
In the next lecture, we will see various examples of priority scheduling in OS.