Priority Scheduling Fundamentals
What you'll learn: How the operating system uses priority values to decide which process gets CPU time first.
The Core Idea
In Priority Scheduling, every process is assigned a priority number (often an integer), and the CPU scheduler always selects the process with the highest priority to run next. Think of it like an emergency room: critical patients (high priority) get treated before those with minor issues (low priority), regardless of arrival order.
How It Works
When multiple processes are ready to run:
- The scheduler examines each process's priority value
- The process with the highest priority executes
- Lower-priority processes wait until higher-priority ones complete or block
Priority conventions vary by system:
- Some systems use lower numbers = higher priority (priority 0 is most important)
- Others use higher numbers = higher priority (priority 99 beats priority 1)
Preemptive vs Non-Preemptive Priority
Non-preemptive: Once a process starts running, it continues until it blocks or terminates—even if a higher-priority process arrives.
Preemptive: If a new process with higher priority arrives, the scheduler immediately pauses the current process and switches to the higher-priority one (similar to how SRTF preempts based on remaining time).
A Real Concern: Starvation
Low-priority processes might never get CPU time if high-priority processes keep arriving. Imagine waiting in that emergency room while ambulances keep bringing critical patients—you could wait indefinitely!
Key Takeaway: Priority Scheduling allocates CPU time based on assigned priority values, ensuring important processes run first, but risks starving low-priority processes if not carefully managed.