Real-Time

4 min read Last updated Tue Jun 09 2026 03:05:56 GMT+0000 (Coordinated Universal Time)

Real-Time Systems

A real-time system is one whose correctness depends on both the results produced and the time at which those results are produced. Implemented as sets of communicating processes reacting to environmental stimuli.

  • Hard real-time
    Incorrect operation if timing constraints are not met. Examples: vehicle braking, insulin pump control, missile guidance.
  • Soft real-time
    Degraded but not incorrect operation if timing is not met. Examples: weather stations, video streaming, UI response.

Embedded Systems

Software component of a hardware/software system that reacts to environmental events. Stored in ROM. Issues control signals in response to stimuli. Normally also a real-time system.

Stimuli

Inputs that trigger system responses.

  • Periodic
    Occur at predictable, fixed time intervals.
  • Aperiodic
    Occur at unpredictable times. Signalled via interrupt.

System Elements

3 process classes in a general embedded real-time model:

  • Sensor control processes
    Collect and optionally buffer data from sensors.
  • Data processor
    Computes system response from collected data.
  • Actuator control processes
    Issue control signals to actuators.

Modelling

State models are the primary design representation. A stimulus triggers a state transition. UML state diagrams show states as nodes and events as arcs.

Design Process

  1. Platform selection
  2. Stimuli/response identification
  3. Timing analysis
  4. Process design
  5. Algorithm design
  6. Data design
  7. Process scheduling

RTOS

Aka. Real-Time Operating System. A lightweight platform providing minimal features for real-time software.

Examples:

  • FreeRTOS
  • Windows CE
  • Apache Nuttx

RTOS vs. Conventional OS

Conventional OSes (such as Linux and macOS) are complex, feature-rich and have large disk footprint. They provide file systems and runtime process management. Coarse-grained process scheduling control.

RTOS strips non-essential features. Omits file management. Optimized for deterministic, fine-grained scheduling.

Components

Real-Time Clock

Provides periodic time ticks for process scheduling.

Interrupt Handler

Manages aperiodic or out-of-frequency requests. On interrupt, control transfers to a predetermined memory address containing a jump to the interrupt service routine (ISR). Further interrupts disabled during ISR execution. ISRs must be short, simple, and fast.

Scheduler

Selects the next process for execution. Driven by clock ticks and interrupt signals.

Resource Manager

Allocates processor and memory to scheduled processes.

Dispatcher

Initiates execution of the selected process on available hardware.

Process Management

Manages concurrent periodic and aperiodic processes. Scheduling based on execution period and deadline.

3 priority levels:

  1. Interrupt level
    Highest. Reserved for time-critical interrupts.
  2. Clock level
    Allocated to periodic processes.
  3. Background
    Lower-priority work.

Interrupt handling is covered in Interrupt Driven IO.

Periodic Processes

Characterized by 3 dimensions:

  • Period
    Time between successive executions.
  • Execution time
    Duration of a single execution.
  • Deadline
    Completion deadline for each instance.

Real-time clock ticks periodically. Each tick generates an interrupt, triggering the process manager for periodic processes.

Scheduling Strategies

May use non-preemptive or preemptive scheduling.

Algorithms:

  • Round robin
  • Rate monotonic
    Processes with shorter periods get higher priority.
  • Shortest deadline first

The resource manager and dispatcher operate in sequence after scheduling.

Architectural Patterns for Embedded Systems

3 common patterns:

  • Observe and React
    Monitors sensors. Triggers alarm or action on exceptional condition. Used in monitoring systems.
  • Environmental Control
    Analyses sensor data and actuator state. Sends control signals to change the environment. Used in control systems.
  • Process Pipeline
    Data moves sequentially through processes linked by synchronized buffers. Used in data acquisition and multimedia systems.

Timing Analysis

3 key factors for each process:

  • Deadline
    Time by which the stimulus must be processed.
  • Frequency
    How many times per second the process must execute.
  • Execution time
    How long it takes to process the stimulus.

Timing analysis results determine process scheduling in the RTOS. All processes must meet their deadlines given their frequency and execution time.

Processor utilisation must satisfy:

U=iCiTi1U = \sum_{i} \frac{C_i}{T_i} \leq 1

Here:

  • CiC_i: execution time of process ii
  • TiT_i: period of process ii
Was this helpful?