Key takeaways
- In a real-time system, correctness includes when a result is produced. The worst case, not the average, decides whether a design is safe.
- Budgets for timing, memory and power are set top-down from requirements and allocated to components, then enforced by measurement on target hardware.
- Priority inversion, unbounded loops, dynamic allocation and shared resources are the usual sources of missed deadlines.
- Timing belongs in continuous integration: a release that exceeds its budget fails the build.
Why the average is the wrong number
Reports of embedded performance often quote average latency or mean CPU load. A hard real-time system does not fail on average. It fails on the single occasion when a task is late, and that occasion is usually the rare coincidence of the slowest path, a competing interrupt and a cache that has gone cold.
The figure that matters is worst-case execution time, together with the worst-case interference from everything else that can run. A design is deterministic only if that bound is known and sits inside the deadline.
Budgeting top-down
Budgets start from requirements and flow down. The end-to-end deadline of a function is divided among the tasks, interrupts and communications on its path, with margin held back for uncertainty. The same is done for memory and for power.
| Resource | Budget set from | Typical enforcement |
|---|---|---|
| Timing | End-to-end deadline of each function and the rate of its inputs. | Worst-case execution time analysis and measured response time under load. |
| Memory | Device capacity, minus bootloader, update slot and margin. | Static allocation, linker-map checks and stack-depth analysis. |
| Power | Battery or supply envelope across operating modes. | Per-mode current measurement and sleep-state verification. |
| Bandwidth | Bus capacity and message rates. | Bus-load analysis and message-loss tests. |
Where deadlines are actually lost
- Priority inversion, where a low-priority task holds a resource a high-priority task needs. Protocols such as priority inheritance bound it.
- Unbounded loops and data-dependent paths whose worst case was never exercised.
- Dynamic allocation, which introduces unpredictable timing and fragmentation. Embedded designs allocate statically.
- Long interrupt handlers and disabled-interrupt sections that delay everything else.
- Shared buses, caches and DMA that create interference not visible in the code.
Measure on the target
Analysis and measurement complement each other. Static analysis gives safe bounds but can be pessimistic. Measurement on real hardware shows what the platform actually does, but only for the cases exercised. Used together, with adversarial inputs and worst-case load, they give a defensible bound.
Practice
Trace tooling on the real device, not a simulator, is the source of truth for timing. Simulation is valuable for logic and scale, and its timing should be treated as indicative until confirmed on hardware.
Timing in continuous integration
Budgets that are checked once at the end of a project are lost within a few releases. Putting them in the pipeline keeps them true. Each build records execution time, stack and memory use, and compares them with the budget. A regression is a failing build, found when the change is made rather than at system integration.
Updates, security and the device lifecycle
Deployed devices cannot usually be recalled. Secure boot, signed images and a rollback strategy have to be designed with the device, including their cost in memory and boot time, so that a failed update never leaves a unit unrecoverable.
These practices apply across robots, vehicles, spacecraft and industrial controllers. The constraints differ and the discipline does not.