Priority and Preemptive Service Disciplines
Rules that decide which job a queue serves next when customers aren't equal — high-priority jobs jump ahead of low-priority ones, and 'preemptive' rules go further by interrupting a lower-priority job already in service.
Prerequisites: Queueing Theory and Birth-Death Processes
The simplest queue serves customers first-come-first-served, but many real systems have classes of jobs that matter more than others — a matching engine's risk checks ahead of routine order updates, or a hospital's trauma cases ahead of scheduled check-ups. A non-preemptive priority discipline lets higher-priority jobs jump the queue but never interrupts a job already being served, so a low-priority job that started first still finishes before a high-priority arrival gets serviced. A preemptive discipline goes further: a high-priority arrival stops the server mid-job on a lower-priority task, which either resumes later from where it left off ("preemptive-resume") or restarts entirely ("preemptive-repeat").
The effect on waiting times is sharp: high-priority jobs see roughly the delay they'd experience in a queue with only other high-priority jobs, largely insulated from the low-priority backlog, while low-priority jobs can wait far longer than in a plain first-come-first-served system, since every fresh high-priority arrival cuts back in front of them. Preemption reduces high-priority delay further still, at the cost of wasted or duplicated work on whatever low-priority job gets interrupted. Designing a priority scheme therefore means weighing that trade-off explicitly: preemptive-resume is attractive when interrupted work can genuinely pick up where it stopped at no cost, but preemptive-repeat or even non-preemptive priority can be the better choice when interruption forces expensive rework, since low-priority delay is a cost too, just one the system is deliberately willing to pay more of.
Priority queueing lets higher-priority jobs go first without interrupting service in progress; preemptive disciplines interrupt a job already running for a higher-priority arrival, trading some wasted work for even shorter high-priority delays.
Related concepts
Practice in interviews
Further reading
- Kleinrock, Queueing Systems Vol. 1, ch. on priority queues