priority scheduling
Think of a hospital emergency room: patients are not seen in arrival order but by urgency — a heart attack jumps ahead of a sprained ankle. Priority scheduling works the same way for processes: each process is assigned a priority number, and the CPU always goes to the ready process with the highest priority, regardless of when it arrived.
How it works: priorities can be set externally (by the user, by importance, by how much was paid) or internally (computed from things like memory needs or expected burst length). The scheduler keeps the ready processes ordered by priority and dispatches the top one. Priority scheduling comes in both flavors: non-preemptive, where a lower-priority job runs to completion once started, and preemptive, where the arrival of a higher-priority process immediately bumps the running one. In fact, shortest-job-first is just priority scheduling where the priority is the inverse of the predicted burst length.
Its central flaw is starvation: a steady stream of high-priority processes can keep a low-priority process waiting indefinitely — it never becomes the most important, so it never runs. The classic story is of a low-priority job submitted in 1967 that supposedly only ran years later when the machine was shut down. The standard cure is aging: gradually raising the priority of any process that has been waiting a long time, so even a humble job eventually rises to the top and gets its turn.
Four ready jobs with priorities 3, 1, 4, 2 (lower number = higher priority here). Preemptive priority scheduling runs the priority-1 job first, then priority-2, then 3, then 4. If priority-1 jobs keep arriving, the priority-4 job may never run at all — that is starvation, which aging is designed to prevent.
Priority scheduling serves the most important job first — at the risk of starving the least important.
Whether a lower or higher priority NUMBER means more urgent is a convention that varies by system (Unix nice values: lower number is higher priority) — always check, because the convention flips between textbooks and real OSes.