Definition
Fixed-priority response-time analysis is a schedulability §9.37 test for tasks, pieces of work that recur, run by one processor under preemptive fixed-priority scheduling: each task has one priority that never changes, and the highest-priority ready task always runs. The analysis computes each task’s worst-case response time §9.32, the longest time from a job’s release (the moment it becomes ready) to its completion, by solving a recurrence. The task set meets every deadline when each worst-case response time is at most its deadline. Joseph and Pandya published the method in 1986.
Where it fits
Main entry: Schedulability (§9.37).
The Schedulability entry states the recurrence and works an example. For a task , let be its worst-case execution time §9.33, let be the shortest time between two releases of a task , and let be the set of tasks with a higher priority than . The worst-case response time is the smallest positive solution of where means rounded up. The sum counts every job of a higher-priority task that can be released, and so preempt task , during . The iteration starts at and recomputes the right-hand side until the value stops changing, a fixed point §3.22. In that entry’s example, task 2 goes from 2 ms to 3 ms and stays at 3 ms.
The result is exact only for the model it was derived for:
one processor, whose scheduler switches to a higher-priority task the moment it becomes ready;
independent tasks, none waiting for a lock, message or result held by another, unless a blocking term, a bound on that waiting, is added;
no self-suspension: a job never sleeps or waits for input or output in the middle of its work;
releases at least apart, with no release jitter, a varying delay between a triggering event and the release;
deadlines no longer than the minimum time between releases, so meeting each deadline rules out overlapping unfinished jobs of the same task;
each a safe upper bound, with the cost of switching between tasks included.
A workqueue §6.36 breaks the central premise. A workqueue is a thread that takes work items, each naming a handler function, from a first-in, first-out §14.14 queue and runs their handlers one at a time, each to completion; items cannot preempt each other. Suppose a 1 ms item is submitted just after a 100 ms handler has started. A high priority for the worker thread does not help: the new item waits for the running handler, and completes about ms after submission even with nothing else queued. The recurrence, applied to the item as if it were a preemptive task, predicts 1 ms.
A workqueue is therefore analyzed on two levels. Among threads, the worker thread is one task whose execution time covers the handlers it may run, and the recurrence, with its extensions, gives the interference from higher-priority threads and interrupts §6.11. Inside the queue, an item’s response time covers the longest handler that can be running, all work that can be queued ahead of it, bounded by an arrival limit for each kind of item, and the item itself, stretched by that interference. Published extensions handle blocking, release jitter and non-preemptive scheduling, each with assumptions of its own.
Limits and common mistakes
Compare each computed response time with its deadline. A task that runs alone for 3 ms every 10 ms has a fixed point of 3 ms on the first iteration. With a 2 ms deadline it still finishes 1 ms late. A deadline guarantee needs both for every task, where is its relative deadline, and evidence that the system meets the model assumptions. A handler that sleeps, takes a lock or waits for another item on the same single worker can delay the queue without bound, or deadlock §9.14 it.
Average or largest measured execution times in place of worst-case bounds give a number, not a guarantee.
Extending the analysis by hand is risky. In 2007, Davis, Burns, Bril and Lukkien showed that the response-time analysis long used for the CAN (Controller Area Network) bus, on which a message is never interrupted once its transmission starts, could underestimate worst-case response times, because it examined only the first transmission of the message under analysis within a busy period, a stretch of time in which the bus is never idle [442].
Questions answered
Can this formula be applied directly to any workqueue?
No, the fixed-priority response-time formula cannot be applied directly to any workqueue, because it is valid only for independent tasks on one processor under preemptive fixed-priority scheduling, with a minimum time between releases, worst-case execution time bounds, no self-suspension and deadlines no longer than the time between releases. A workqueue, a thread that runs queued work items one at a time in first-in, first-out order, breaks the central premise: its items do not preempt each other, so an item waits for the handler that is running and for every item queued ahead of it, whatever priority the worker thread has. A 1 ms item submitted just after a 100 ms handler starts completes about 101 ms later, where the formula, applied to the item as if it were a preemptive task, predicts 1 ms.
To analyze a workqueue, model it as it runs: apply the formula, extended where needed for blocking, release jitter and self-suspension, to the worker thread among the other threads and interrupts; inside the queue, add the longest handler that can be running and all work that can be queued ahead of the item, bounded by an arrival limit for each kind of item. Use worst-case execution time bounds, not averages, for a hard guarantee. Convergence gives a response time. Compare it with the deadline for each task and verify that the code satisfies the model assumptions.
Related entries: Worst-case execution time (WCET) (§9.33), Priority inversion (§9.16), Zephyr workqueue (§6.36), Cooperative and preemptive scheduling (§6.37), Callback dependency deadlock across a workqueue (§19.4.9), Duty-cycle bound versus per-request response-time bound (§19.4.6). Further reading: [89, 442].