The short answer
The four main types of processor scheduling policies usually taught in operating systems courses are:
- First-come, first-served (FCFS): run tasks in the order they arrive, each to completion.
- Shortest job first (SJF): run the task with the shortest expected CPU burst next.
- Priority scheduling: run the task with the highest priority next.
- Round robin (RR): give each ready task a fixed time slice in turn, then move to the next.
Each one answers the same question (“which ready task gets the processor next?”) with a different rule. Real operating systems combine and refine these ideas, and real-time systems lean heavily on priority scheduling. The rest of this article explains each policy, how they’re compared, and what operating systems and embedded RTOSes actually use.
The four policies explained
First-come, first-served
FCFS keeps a simple FIFO queue of ready tasks. The task at the front runs until it finishes or blocks, then the next one runs.
- Preemptive? No.
- Strengths: trivial to implement, no starvation (every task eventually runs), and predictable ordering.
- Weaknesses: the convoy effect. One long task at the front makes every short task behind it wait, so average waiting time can be poor. Urgent work gets no special treatment.
- Where you see it: batch-style job queues, and the simplest embedded designs where work items are processed in arrival order.
Shortest job first (and shortest remaining time first)
SJF picks the ready task with the shortest next CPU burst. Its preemptive version, shortest remaining time first (SRTF), also switches to a newly arrived task if that task’s burst is shorter than what remains of the running one.
- Preemptive? SJF is usually described as non-preemptive. SRTF is the preemptive variant.
- Strengths: when all tasks are available at the same time, SJF gives the minimum average waiting time of any non-preemptive policy.
- Weaknesses: it needs to know burst lengths in advance, which is rarely possible, so real systems estimate them from past behavior. Long tasks can starve if short ones keep arriving.
- Where you see it: mostly in theory and in batch systems with known job lengths. It’s rarely used directly in embedded systems.
Priority scheduling
Each task has a priority, and the scheduler always picks the highest-priority ready task. Ties are broken by another rule, often FCFS or round robin.
- Preemptive? Either. In preemptive priority scheduling, a newly ready higher-priority task interrupts the running one. In the non-preemptive form, it waits for the current task to finish.
- Strengths: urgent work can be served first, and response time for high-priority tasks is good.
- Weaknesses: low-priority tasks can starve. General-purpose systems counter this with aging, which gradually raises the priority of tasks that have waited a long time. Real-time systems usually don’t age priorities, and instead rely on analysis to show every task gets enough time.
- Where you see it: almost every RTOS, and the real-time policies of general-purpose operating systems. SJF can be seen as a special case where priority is set by burst length.
Round robin
Round robin gives each ready task a fixed time quantum (time slice). When the quantum expires, the task goes to the back of the queue and the next one runs.
- Preemptive? Yes, by the timer at the end of each quantum.
- Strengths: fair, with no starvation, and good response time for interactive work because every task gets a turn soon.
- Weaknesses: performance depends on the quantum. If it’s too long, round robin behaves like FCFS. If it’s too short, context-switch overhead eats into useful work. It ignores urgency entirely.
- Where you see it: time-sharing systems, and in RTOSes as a way to share time among tasks of equal priority.
For a worked example that runs the same four tasks through all four policies and compares waiting times, see the four main types of scheduling algorithms.
Comparison table
| FCFS | SJF / SRTF | Priority | Round robin | |
|---|---|---|---|---|
| Picks next task by | Arrival order | Shortest (remaining) burst | Highest priority | Turn order, with time slices |
| Preemptive | No | SJF no, SRTF yes | Either | Yes |
| Starvation possible | No | Yes, for long tasks | Yes, for low priority | No |
| Needs advance knowledge | No | Burst lengths | Priorities | Quantum size |
| Main strength | Simplicity | Lowest average wait | Urgent work first | Fairness and responsiveness |
| Main weakness | Convoy effect | Burst lengths unknown | Starvation | Ignores urgency |
Preemptive vs non-preemptive policies
The policies above split into two groups:
- Non-preemptive: once a task gets the CPU, it keeps it until it finishes or blocks voluntarily. FCFS, SJF, and non-preemptive priority work this way.
- Preemptive: the scheduler can take the CPU away from a running task, because a higher-priority task became ready or a time slice expired. SRTF, preemptive priority, and round robin work this way.
Preemption improves responsiveness but costs context switches, and it means tasks can be interrupted partway through updating shared data. Embedded developers have to handle that with mutexes, queues, and similar tools, covered in RTOS task synchronization and inter-task communication.
How policies are judged
Operating systems textbooks compare policies using a standard set of criteria:
- CPU utilization: the fraction of time the CPU does useful work.
- Throughput: tasks completed per unit of time.
- Turnaround time: time from a task’s arrival to its completion.
- Waiting time: time a task spends in the ready queue.
- Response time: time from arrival to the first time the task runs.
General-purpose systems try to balance these on average. Real-time systems add a criterion that overrides the rest: every deadline must be met in the worst case. A policy with excellent average response time can still be wrong for a real-time system if it occasionally delays an urgent task. That’s why real-time scheduling uses different tools, like rate-monotonic priority assignment and response-time analysis, described in real-time scheduling and multitasking in embedded systems.
Policy, algorithm, and scheduler: what’s the difference?
The three words are often used interchangeably, but they can mean different things:
- A policy is the rule: “always run the highest-priority ready task.”
- An algorithm is how that rule is implemented: for example, a bitmap of ready priorities plus a list per priority, so the scheduler can find the highest ready one in constant time.
- The scheduler is the part of the operating system kernel that applies the policy whenever something changes.
The three types of schedulers
In general-purpose operating systems, textbooks describe three levels of scheduler:
- Long-term scheduler (job scheduler): decides which jobs are admitted into the system for execution. It mattered most in batch systems.
- Medium-term scheduler: temporarily removes processes from memory (swapping them out) and brings them back, to control how many compete for RAM.
- Short-term scheduler (CPU scheduler): picks which ready process or thread runs next on the CPU. This is the one the four policies describe, and it runs very frequently.
Embedded RTOSes on microcontrollers typically have only the short-term scheduler. All tasks are usually created at startup, and there’s no swapping.
Scheduling policies in real operating systems
Real operating systems expose named policies that build on the textbook ideas. On Linux, which matters for embedded Linux and real-time Linux work, the main ones are:
| Policy | What it does | Textbook relative |
|---|---|---|
SCHED_FIFO |
Fixed-priority real-time. A task runs until it blocks, yields, or is preempted by a higher priority. | Preemptive priority with FCFS among equals |
SCHED_RR |
Like SCHED_FIFO, but tasks at the same priority share time in slices. |
Preemptive priority with round robin among equals |
SCHED_OTHER (SCHED_NORMAL) |
The default time-sharing policy for ordinary processes, which aims for fairness. | A refined, weighted form of fair sharing |
SCHED_DEADLINE |
Each task declares a runtime, period, and deadline. The kernel schedules by earliest deadline and enforces each task’s budget. | Earliest deadline first (EDF) |
SCHED_FIFO and SCHED_RR are defined by POSIX. SCHED_DEADLINE is Linux-specific. Linux also has SCHED_BATCH and SCHED_IDLE for background work. Real-time tasks on Linux typically use SCHED_FIFO, often on a kernel with the PREEMPT_RT capabilities to reduce latency.
What embedded RTOSes use
Most microcontroller RTOSes, including FreeRTOS, Zephyr, and ThreadX, use fixed-priority preemptive scheduling, with optional round-robin time slicing among tasks of equal priority. In other words, they combine two of the four classic policies: priority to decide who runs, and round robin to share time among equals.
They don’t use SJF, because burst lengths aren’t known at run time. They don’t use plain FCFS or round robin for time-critical work either, because neither respects urgency. Instead, developers assign priorities by timing requirements, often rate-monotonically (shorter period, higher priority), and verify that every task meets its deadline. Some very simple systems skip the RTOS and use a cooperative loop. See RTOS vs super loop for when that’s enough.
Frequently asked questions
Which processor scheduling policy is best?
It depends on what you’re optimizing. SJF minimizes average waiting time when burst lengths are known. Round robin gives the best fairness and interactive response. Preemptive priority scheduling is the standard choice when some work is more urgent than other work, which is why real-time systems use it.
Is priority scheduling preemptive or non-preemptive?
It can be either. Most modern operating systems and every common RTOS use the preemptive form, where a higher-priority task interrupts a lower-priority one as soon as it becomes ready.
Why is SJF not used in real-time systems?
SJF needs to know how long each task will run before it runs, and it optimizes average waiting time, not deadlines. Real-time systems care about worst-case response time for each task, which SJF doesn’t address. It can also starve long tasks.