How do you choose task priorities? Explain rate-monotonic scheduling.
Short answer: For periodic tasks, rate-monotonic scheduling (RMS) assigns higher fixed priorities to tasks with shorter periods (higher rates). For independent periodic tasks with deadlines equal to their periods, RMS is optimal among fixed-priority policies, and a task set is guaranteed schedulable if total utilisation U = Σ Cᵢ/Tᵢ ≤ n(2^(1/n) − 1), which approaches 69.3% for large n. Above that bound a set may still be schedulable, which you check with exact response-time analysis.
Liu & Layland bound values
| n tasks | Bound |
|---|---|
| 1 | 100% |
| 2 | 82.8% |
| 3 | 78.0% |
| 4 | 75.7% |
| ∞ | 69.3% |
Variants
- Deadline-monotonic (DMS): priority by relative deadline (shorter deadline = higher priority); optimal when deadlines are shorter than periods.
- EDF (earliest deadline first): dynamic priorities; schedules any set with U ≤ 100% (deadline = period) but is harder to implement and behaves badly under overload (many tasks can miss). Linux
SCHED_DEADLINEuses EDF.
Practical priority assignment beyond the theory
- Interrupt handlers do minimal work and defer to tasks.
- Hard-deadline control loops get the highest task priorities, by rate.
- Communication handlers (with latency requirements) next.
- User interface, logging and housekeeping lowest.
- Tasks that only react to events get priorities based on how fast they must react (their deadline).
- Avoid many tasks at the same priority unless they are equally important.
Validate with measurement: trace tools (Percepio Tracealyzer, SEGGER SystemView) show response times, CPU load and blocking, which reveals when theory and reality differ (interrupts, blocking on shared resources, cache effects).