Independent learning for embedded-systems engineersHardware · Firmware · Software
TEA-105CORE EMBEDDED SYSTEMS TOPICFOUNDATION

Real-time behaviour

Design for the right result at the right time: express deadlines, control interference and demonstrate timing under credible worst-case conditions.

After this module, you should be able to:

  • Translate behaviour into timing requirements
  • Choose an appropriate execution model
  • Recognise scheduling and concurrency hazards
  • Plan convincing timing verification
01 / TIMING MODEL

Real-time means bounded response, not simply fast execution.

A system is real-time when correctness depends on both the logical result and when that result is produced. Average performance is therefore insufficient: the architecture must make important timing limits explicit and control the conditions that can delay them.

EVENTWhen does the clock start?Interrupt, sample, message, state entry or physical threshold crossing
RESPONSEWhat work must complete?Detect, calculate, decide, command, confirm or enter a safe response
DEADLINEHow late is unacceptable?A bound derived from physics, control stability, safety or user-visible behaviour
TermMeaningWhy it matters
LatencyDelay from an event to the start or completion of its response.Determines whether an external event is handled in time.
JitterVariation in timing between otherwise comparable executions.Can disturb sampling, control loops and communications.
WCETWorst-case execution time for a bounded software operation.Supports response-time and schedulability analysis.
PeriodRequired interval between repeated releases or executions.Defines sampling and control cadence.
DeadlineLatest acceptable completion relative to a defined event.Separates acceptable timing from failure.
“Runs every 10 ms” is incomplete.State the release source, permitted jitter, completion deadline, overrun response and relationship to the physical process.
02 / EXECUTION

Choose an execution model whose timing can be understood.

ModelStrengthsTypical risks
Cyclic executiveSimple sequence, low overhead and timing that can be easy to inspect.One long activity delays everything; rates and blocking operations need discipline.
Interrupt-drivenLow response latency for asynchronous hardware events.Excess work, nesting, shared data and priority interactions make behaviour opaque.
RTOS tasksExplicit priorities, blocking, timers and separation of activities.Priority inversion, starvation, deadlock, stack use and configuration errors.
Event / state modelClear behavioural transitions and work triggered by meaningful events.Queues can overflow; long handlers and event storms can break assumptions.

Many products combine these models: a short interrupt captures an event, a high-priority task performs time-critical processing, and lower-priority tasks handle reporting or storage. The design must still have one coherent priority and resource-sharing policy.

Control interference deliberately

  • Keep interrupt service routines short, bounded and non-blocking.
  • Assign priorities from deadlines and interference analysis, not perceived importance.
  • Use queues, immutable messages or carefully bounded critical sections for shared data.
  • Give blocking calls, retries and memory allocation explicit timing policies.
  • Monitor missed deadlines, queue high-water marks, execution time and stack margin.
03 / ANALYSIS

Trace the complete timing path.

  1. Start from the physical need. Derive sampling, actuation and fault-response deadlines from system behaviour.
  2. Map the path. Include sensors, buses, DMA, interrupts, tasks, algorithms, outputs and mechanical response.
  3. Bound each contributor. Account for execution, pre-emption, blocking, transfer time, retries and clock tolerance.
  4. Analyse interference. Consider higher-priority work, shared resources, interrupt bursts and simultaneous events.
  5. Define overload behaviour. Decide what may be dropped, deferred, degraded or treated as a fault.
  6. Measure under stress. Exercise maximum load, longest messages, cold start, diagnostic activity and credible faults.

Worked example: 1 kHz motor-control loop

The loop has a 1 ms period, but the useful deadline is earlier because the PWM register must update before the next hardware latch point.

Timer triggerADC conversionDMA completeControl task releasedAlgorithm executesPWM updated

If acquisition consumes 80 µs, release and interference can consume 120 µs, the algorithm takes up to 210 µs and the output update needs 20 µs, the design has a 430 µs bounded path before adding margin. Trace measurements should confirm the bound while communications and diagnostics generate their maximum credible load.

04 / EVIDENCE

Make timing claims reviewable and repeatable.

Timing requirements

Defined events, periods, deadlines, jitter limits, overload responses and rationale.

Execution model

Tasks, interrupts, priorities, activation sources, shared resources and blocking policy.

Timing analysis

WCET assumptions, response-time calculations, bus timing and allocated margins.

Instrumented traces

Timestamped evidence showing release, execution, pre-emption and completion.

Stress results

Measurements at maximum credible CPU, bus, interrupt, storage and fault load.

Runtime monitoring

Overrun counters, queue depth, watchdog servicing, stack margin and diagnostic handling.

Common failure patterns

Average-time assurance

Typical measurements look comfortable, but a rare worst-case path misses the deadline.

Priority by seniority

Tasks called “critical” receive high priority without analysing deadlines and interference.

Long interrupt handlers

Convenient processing inside an interrupt creates uncontrolled latency elsewhere.

Debug-build confidence

Instrumentation changes timing, while the released configuration is not equivalently characterised.

05 / REFERENCES

Further learning

KEY TAKEAWAY

Deadlines must survive interference.

Real-time assurance comes from defined timing requirements, bounded execution and evidence collected under credible worst-case conditions—not from a fast processor or low average CPU load.