Section 9.37

Schedulability

Definition

A set of tasks, pieces of work that recur, is schedulable under a scheduling policy when every occurrence of every task, called a job, finishes by its deadline, for every pattern of arrivals and execution times §9.32 that the task model allows. Schedulability is that property. A schedulability test decides it without running the system, from each task’s worst-case execution time §9.33, minimum time between arrivals and deadline. The answer belongs to the task set and the scheduler together: the same tasks can be schedulable under one policy and not under another.

The idea

A processor that is busy only 40% of the time can still miss a deadline. A task that needs 4 milliseconds (ms) of processor time and must finish within 2 ms of its release fails every time, even if it arrives only every 10 ms, so that the processor is busy 4/10=40%4 / 10 = 40\% of the time. Average load says how much work there is. It does not say when the work is needed or what the scheduler runs first.

Schedulability analysis therefore looks for the worst case instead of the average. Under fixed priorities, a job is delayed most when it is released at the same instant as a job of every higher-priority task, and those tasks then release new jobs as fast as they are allowed to. Liu and Layland proved this in 1973 for periodic tasks under preemptive fixed-priority scheduling, and called that instant the critical instant. A job that meets its deadline in that situation meets it in every situation the model allows.

How it works

The task model fixes the inputs. For each task ii:

The utilization of task ii is Ui=Ci/TiU_i = C_i / T_i, the long-run fraction of processor time it can demand, and the total utilization UU is the sum over all tasks.

One condition is necessary under every policy on one processor: if U>1U > 1, the tasks can demand more processor time than exists, work piles up, and some deadline is eventually missed. U≤1U \le 1 is not sufficient in general. Beyond that, the right test depends on the policy. The three classic cases assume one processor, preemption and independent tasks:

Fixed-priority response-time analysis. The worst-case response time RiR_i of task ii is its own execution plus the interference from higher-priority tasks, meaning the time those tasks take the processor during the response. Starting from a critical instant, a higher-priority task jj releases at most ⌈Ri/Tj⌉\lceil R_i / T_j \rceil jobs in a window of length RiR_i, where ⌈x⌉\lceil x \rceil means xx rounded up to a whole number, and each of those jobs costs at most CjC_j. Because RiR_i appears on both sides of that statement, compute it by iteration:

  1. Start with R=CiR = C_i.

  2. Compute CiC_i plus, for every higher-priority task jj, ⌈R/Tj⌉×Cj\lceil R / T_j \rceil \times C_j.

  3. If the result equals RR, it is the worst-case response time: stop. If it exceeds DiD_i, the task can miss its deadline: stop. Otherwise set RR to the result and repeat step 2.

The values never decrease from one round to the next, so the iteration either settles or passes the deadline.

This basic analysis assumes: one processor; fixed, distinct priorities; full preemption, so that a higher-priority job takes the processor as soon as it is released; independent tasks that share no locks; deadlines no larger than periods; no release jitter, meaning that every job is released exactly when it arrives; no self-suspension, meaning that a job never gives up the processor to wait for something; and scheduler and interrupt §6.11 overheads that are either zero or included in the CjC_j. Extensions add a blocking term BiB_i, the longest time task ii can wait for a lower-priority task that holds a resource task ii needs, and a jitter term for late releases. Priority inheritance §9.17, which lends the lock holder the priority of the highest-priority task waiting for the lock, is one protocol that keeps BiB_i bounded.

Worked example

Three tasks share one processor with fixed priorities. All times are in milliseconds, and each deadline equals the period:

The priorities are rate-monotonic. The utilization is 1/4+2/6+3/13≈0.250+0.333+0.231=0.8141/4 + 2/6 + 3/13 \approx 0.250 + 0.333 + 0.231 = 0.814. The Liu and Layland bound for three tasks is 3(21/3−1)≈3×0.260=0.7803(2^{1/3} - 1) \approx 3 \times 0.260 = 0.780. Since 0.814>0.7800.814 > 0.780, the utilization test is inconclusive.

Response-time analysis decides the question. Task 1 has no higher-priority task, so R1=1≤4R_1 = 1 \le 4. For task 2, start at R=2R = 2; then 2+⌈2/4⌉×1=2+1=32 + \lceil 2/4 \rceil \times 1 = 2 + 1 = 3; then 2+⌈3/4⌉×1=32 + \lceil 3/4 \rceil \times 1 = 3, unchanged, so R2=3≤6R_2 = 3 \le 6. For task 3, start at R=3R = 3:

So R3=10≤13R_3 = 10 \le 13. All three tasks meet their deadlines: the set is schedulable although it fails the utilization test.

A timeline confirms the result. All three tasks release a job at time 0. Task 1 runs from 0 to 1, task 2 from 1 to 3, and task 3 from 3 to 4. Task 1’s second job, released at 4, runs from 4 to 5, and task 3 continues from 5 to 6. Task 2’s second job, released at 6, runs from 6 to 8. Task 1’s third job, released at 8, runs from 8 to 9. Task 3 runs its last millisecond from 9 to 10 and finishes at 10, as computed.

Stated precisely

Basic fixed-priority response-time analysis. Let hp(i)\mathrm{hp}(i) be the set of tasks with a priority higher than that of task ii. The worst-case response time RiR_i is the smallest positive solution of Ri=Ci+∑j∈hp(i)⌈RiTj⌉Cj.R_i = C_i + \sum_{j \in \mathrm{hp}(i)} \left\lceil \frac{R_i}{T_j} \right\rceil C_j. It is found by the iteration Ri(0)=CiR_i^{(0)} = C_i and Ri(k+1)=Ci+∑j∈hp(i)⌈Ri(k)/Tj⌉CjR_i^{(k+1)} = C_i + \sum_{j \in \mathrm{hp}(i)} \lceil R_i^{(k)} / T_j \rceil C_j, where the superscript (k)(k) numbers the round and is not a power. The task set is schedulable exactly when Ri≤DiR_i \le D_i for every task ii. This holds under the assumptions listed in How it works, with each CjC_j a safe WCET bound and each TjT_j a true minimum time between releases.

Utilization tests, for one processor, preemption, and independent periodic tasks with Di=TiD_i = T_i: earliest deadline first schedules the set if and only if ∑iCi/Ti≤1\sum_i C_i / T_i \le 1. Rate-monotonic fixed priorities schedule the set if ∑iCi/Ti≤n(21/n−1)\sum_i C_i / T_i \le n(2^{1/n} - 1), where nn is the number of tasks. The second test is sufficient only.

With a blocking bound BiB_i, the longest time task ii can wait for a lower-priority task that holds a shared resource, the equation becomes Ri=Ci+Bi+∑j∈hp(i)⌈Ri/Tj⌉CjR_i = C_i + B_i + \sum_{j \in \mathrm{hp}(i)} \lceil R_i / T_j \rceil C_j.

Limits and common mistakes

The inputs decide everything. An execution time taken from the largest measurement instead of a proven WCET bound, or an arrival rate that the real system can exceed, gives a correct calculation about a different system.

Utilization below 100% does not mean schedulable, as the task that needs 4 ms within a 2 ms deadline shows. Utilization above the rate-monotonic bound does not mean unschedulable, as the worked example shows.

Each theorem has its own assumptions. Shared locks need a blocking term. Tasks that wait for devices need a self-suspension analysis. Late releases need a jitter term. Cooperative scheduling §6.37, where a running job keeps the processor until it gives it up, needs a non-preemptive analysis. Several processors need multiprocessor analyses, because the one-processor results do not carry over.

Interrupt handlers §6.12 run above every task priority. Their execution, at their highest possible rate, must enter the analysis as the highest-priority tasks.

A schedulability result covers only the tasks in the model. Work outside the model, such as a logging thread added later or a callback §14.22 queued on a shared worker, takes processor time that the analysis did not count.

Schedulable is a yes-or-no statement about deadlines. It says nothing about average latency, and a schedulable system can still respond slowly when its deadlines are long.

Questions answered

What utilization or response-time analysis applies to this scheduling policy?

The analysis that applies is the one whose assumptions match the policy and the tasks; a schedulability analysis, which decides whether every job meets its deadline, is valid only within its stated model. Let CiC_i be task ii’s worst-case execution time, TiT_i its period or minimum time between releases, and RiR_i its worst-case response time. For one processor with preemption and independent tasks:

Shared locks add a blocking term and late releases add a jitter term. Cooperative or non-preemptive scheduling, tasks that suspend themselves, and multiple processors each need their own extended analysis. Whatever the test, its inputs must be proven worst-case execution times and true minimum times between releases, including those of the interrupt handlers; otherwise the result describes a model, not the system.

Related entries: Worst-case execution time (WCET) (§9.33), Priority inversion (§9.16), Response time versus execution time (§9.32), Fixed-priority response-time analysis (§19.4.7), Priority inheritance (§9.17), Cooperative and preemptive scheduling (§6.37), Real-time system (§6.34), Duty-cycle bound versus per-request response-time bound (§19.4.6). Further reading: [86, 89].