1. Priority-Based Non-Preemptive Scheduling
Definition:
In Priority Non-Preemptive Scheduling, each process is assigned a priority.
The CPU is allocated to the process with the highest priority (smallest number = highest priority).
Once the CPU is given to a process, it cannot be taken away until the process finishes, even if a higher-priority process arrives.
Key Features:
- Type: Non-preemptive
- Basis: Process priority
- Higher priority → executed first
- If priorities are same → FCFS is used
- CPU is not interrupted once assigned
Example:
| Process | Burst Time (ms) | Priority |
|---|---|---|
| P1 | 10 | 3 |
| P2 | 1 | 1 |
| P3 | 2 | 2 |
Execution Order:
→ P2 (Priority 1) → P3 (Priority 2) → P1 (Priority 3)
Gantt Chart:
| P2 | P3 | P1 |
0 1 3 13
Advantages:
✅ Simple to implement
✅ Lower-priority tasks do not preempt higher-priority ones
✅ Good for batch systems
Disadvantages:
❌ Starvation (low-priority processes may never execute)
❌ No preemption — less responsive
2. Priority-Based Preemptive Scheduling
Definition:
In Priority Preemptive Scheduling, the CPU is also assigned to the highest-priority process,
but if a new process arrives with a higher priority than the currently running one, the CPU is preempted and given to the new process.
Key Features:
- Type: Preemptive
- CPU can be taken away if a higher-priority process arrives
- Higher responsiveness than non-preemptive version
Example:
| Process | Arrival Time | Burst Time | Priority |
|---|---|---|---|
| P1 | 0 | 5 | 2 |
| P2 | 1 | 3 | 1 |
Execution Order:
- At time 0 → P1 starts (priority 2)
- At time 1 → P2 arrives (priority 1, higher) → P1 is preempted
- CPU switches to P2 → completes
- Then P1 resumes
Gantt Chart:
| P1 | P2 | P1 |
0 1 4 9
Advantages:
✅ Better response time for high-priority processes
✅ More efficient CPU utilization
Disadvantages:
❌ Starvation for low-priority processes
❌ More context switches (less efficient)
Difference Summary:
| Feature | Priority Non-Preemptive | Priority Preemptive |
|---|---|---|
| CPU control | Process keeps CPU until completion | CPU can be taken by higher-priority process |
| Response time | Slower | Faster |
| Context switching | Less | More |
| Starvation | Possible | More likely |
| Type | Non-preemptive | Preemptive |