HLA compliant real-time operating system simulation

Rui Mao2002 · DOI

In the world of embedded systems, waiting for target hardware to arrive before testing your software is a recipe for project delays. Developers often turn to simulations to bridge this gap. This 2002 thesis by Rui Mao from Carleton University explores a sophisticated way to do just that by leveraging a distributed simulation standard called the High Level Architecture (HLA).

TL;DR

This research presents a multitasking Real-Time Operating System (RTOS) simulator built on the High Level Architecture (HLA) framework. It allows developers to execute and test embedded software on a standard Linux workstation, enabling early-stage debugging and rigorous schedulability analysis before target hardware even exists.

What Problem Does This Paper Address?

Embedded system design is a balancing act of hardware and software components developed in parallel. Testing software on "non-stable" target hardware is notoriously difficult—when a bug occurs, is it the code, the silicon, or the interaction between them?

While RTOS simulators exist, many lack the modularity needed for modern component-based design. Mao identifies a need for a simulation environment that is:

  1. Interoperable: Able to combine different simulation components easily.
  2. Deterministic: Capable of accurately simulating timing constraints like deadlines and execution times.
  3. Accessible: Running on stable host workstations (like Linux) rather than expensive, specialized hardware.

Methods

The core innovation is mapping RTOS concepts onto the High Level Architecture (HLA), an IEEE standard (1516) originally developed by the US Department of Defense for distributed simulations.

  • The RTOS Federation: The simulation is structured as a "federation" of separate processes (federates). This includes an RTOS Kernel Federate (the scheduler), multiple Task Federates (representing application code), and a Semaphore Initialization Federate.
  • Discrete Event Simulation: Unlike real-time execution, simulation time is controlled by the kernel federate. It uses Worst Case Execution Time (WCET) estimates to advance the clock.
  • Scheduling: The system implements a uniprocessor, periodic, static priority-based preemptive scheduler (Rate Monotonic).
  • Inter-Task Communication (ITC): The author simulates POSIX-style semaphores and shared memory. Since HLA federates have separate address spaces, shared memory is simulated by replicating data across federates and using HLA interactions to keep them synchronized.
  • The Conversion Process: The paper outlines a manual workflow to transform a standard C++ real-time application into a "simulation application" that can talk to the HLA Run-Time Infrastructure (RTI).

Datasets

As this is a systems and architecture paper rather than a machine learning study, it does not use traditional datasets. Instead, the framework is evaluated using a Producer-Consumer example application. This application features a producer and consumer task sharing a circular buffer, synchronized by three semaphores (mutex, nempty, and nstored).

Key Insights and Ideas

  • HLA as the "Glue": Using HLA allows the RTOS kernel and the application tasks to exist as independent components. This modularity makes the simulation highly reusable and extensible.
  • Control Points: To handle preemption in a simulation where tasks don't actually "run" for real-time duration, the author introduces "control points" (synchronization calls or end-of-period markers). Tasks report the WCET needed to reach the next control point, allowing the kernel to schedule them accurately on a simulated timeline.
  • Simulated Shared Memory: A clever workaround for distributed systems: by using HLA interactions to broadcast updates, the simulator mimics a shared memory environment even though the tasks are running in separate Linux processes.

Key Results

  • Functional Prototype: The author successfully implemented the simulator on Linux 6.2 using C++ and HLA RTI services.
  • Deadline Detection: The simulation proved capable of identifying timing failures. In the Producer-Consumer test case, the simulator correctly detected that the producer task missed its 14th period deadline at simulated time 168, triggering a simulation stop.
  • Schedulability Analysis: The tool provides a practical environment for "Rate Monotonic Analysis," allowing researchers to verify if a set of tasks is schedulable under worst-case conditions.

Limitations and Future Work

  • Manual Transformation: Currently, converting a real-time program into a simulation program is a manual process. The author suggests developing an automatic code transformation tool.
  • Uniprocessor Only: The current model is limited to single-processor systems. Future work could extend this to multiprocessor RTOS simulations.
  • Missing Features: The simulator does not yet support I/O simulation or advanced IPC mechanisms like message queues and mailboxes.
  • Priority Inversion: The current kernel does not implement protocols (like Priority Inheritance) to solve the unbounded priority inversion problem, though the author identifies this as a key area for future functional expansion.

Summary updated

BibTeX
@misc{mao2002hla,
  author = {Rui Mao},
  title = {{HLA compliant real-time operating system simulation}},
  year = {2002},
  doi = {10.22215/etd/2002-05330},
}
Figure