QP/C++ 8.1.2
Real-Time Event Framework
Loading...
Searching...
No Matches
Overview

About this DocumentActive Objects

QP real-time event frameworks (RTEFs) form a family of lightweight implementations of the Active Object model of computation specifically designed for real-time embedded (RTE) systems (such as ARM Cortex-M based MCUs). QP/C++ Frameworks provide both a software infrastructure for building QP/C++ Applications consisting of Active Objects (Actors) and a runtime environment for executing the Active Objects in real-time. Additionally, QP/C++ Framework supports Hierarchical State Machines with which to specify the behavior of Active Objects [UML-2.5], [Sutter:10], [ROOM:94].

Remarks
The features and requirements described in this Software Requirement Specification can be ultimately implemented in various programming languages, so this document applies to a whole family of QP RTEFs, currently consisting of QP/C, QP/C++, SafeQP/C, and SafeQP/C++ frameworks implemented in C and C++, respectively. Other possible implementations (e.g., QP/Rust) of these requirements and features might be added in the future.

Goals

The main goals of the QP/C++ Framework are:

  • to provide a modern, event-driven model of concurrency based on the best practices of concurrent programming [Sutter:10], [Cummings:10], [ROOM:94], collectively known as the Active Object (Actor) model of computation.:
  • to provide an inherently safer concurrent programming model than the traditional "shared-state concurrency, mutual-exclusion, and blocking" approach based on a conventional Real-Time Operating System (RTOS);
  • to provide a higher-level of abstraction closer to the problem domain than the "naked" RTOS threads;
  • to provide the right abstractions for applying modern techniques like Hierarchical State Machines, visual modeling, and automatic code generation;
  • to bridge the semantic gap between the higher level UML concepts (such as Events, Hierarchical State Machines, and Active Objects) and the traditional programming languages like C or C++.

Functional Safety

In the context of functional safety standards and certification, QP/C++ Frameworks offer numerous advantages over the traditional "shared state concurrency" based on a "naked" Real-Time Operating System (RTOS). QP/C++ Frameworks implement an inherently safer model of concurrency and many best practices recommended by functional safety standards (e.g., [IEC 61508-7:2010]) such as:

  • Structured methods ([IEC 61508-7:2010] C.2.1)
  • Semi-formal methods, such as Hierarchical State Machines ([IEC 61508-7:2010] Table.B.7)
  • Computer-aided design tools ([IEC 61508-7:2010] B.3.5)
  • Defensive programming, including Failure Detection and Failure Assertion Programming ([IEC 61508-7:2010] C.2.5)
  • Modular approach ([IEC 61508-7:2010] Table.B.9)
  • Design and coding standards, including safe subsets of C or C++ ([IEC 61508-7:2010] C.2.6)
  • Structured programming ([IEC 61508-7:2010] C.2.7)
  • Traceability between requirements and software design ([IEC 61508-7:2010] C2.11)

Context of Use

The following block diagram shows the context of use and the high-level functional decomposition of a system built with the QP/C++ Framework.

Figure SRS-BLK: Block diagram showing the context and functional decomposition of a system based on QP/C++ Framework.

[1] QP/C++ Application:

  • defines event-driven Active Objects that collectively deliver the intended functionality;
  • defines Custom Error Handler that is responsible for achieving Safe State;
  • defines interrupts (Interrupt Service Routines) that produce events for the Active Objects

[2] QP/C++ Framework:

[3a] Real-Time Kernel provides scheduling and execution context for the Active Objects. This could be one of the kernels built-into QP/C++ Frameworks (QV, QK, or QXK); or

[3b] Alternatively, QP/C++ Framework can run on top of a 3-rd party RTOS kernel; or

[3c] Alternatively, QP/C++ Framework can run on top of a General-Purpose OS (e.g., Linux/POSIX or Windows);

[4] Board Support Package (BSP) consists of the low-level support code;

[5] Target Hardware (MCU + external components).

Inversion of Control

Like most event-driven systems, the QP/C++ Framework is based on inversion of control, which means that the control of code execution resides in the QP/C++ Framework rather than the QP/C++ Application based on QP. Specifically, to handle events, QP/C++ Framework calls the QP/C++ Application, and not the other way around. Of course, QP/C++ Applications can also call services provided in QP/C++ Framework, but the main flow of control always begins with the QP/C++ Framework.

Framework, NOT a Library

That inversion of control gives the event-driven infrastructure (QP) all the defining characteristics of a framework rather than a library.

The main difference between a framework and a library is that when you use a library, such as a conventional RTOS, you write the main body of each thread, and you call the library code that you want to reuse (e.g., a semaphore). When you use a framework, such as QP, you reuse the main body and write the code it calls (inversion of control).

Deriving Application from a Framework

The mechanism for deriving an application from a software framework, such as QP, is by inheriting the base classes provided by the framework and specializing them for the application at hand. (See also the extensibility characteristics of a framework enumerated above.)

Main Use Cases

The use case diagram depicted in Figure SRS-USE shows the main users and typical use cases they engage in.

Figure SRS-USE: Users and main use cases of QP/C++ Application and QP/C++ Framework.

[1] QP/C++ Application use cases (use QP/C++ Framework [2] use cases):

  • Application Developer (actor) develops QP/C++ Application consisting of Active Objects
  • Application Developer (actor) optimizes QP/C++ Application
  • Application Developer (actor) maintains QP/C++ Application by modifying Active Objects
  • Application Developer (actor) traces QP/C++ Application to debug, profile, optimize
  • Application Developer (actor) or Application Tester (actor) tests QP/C++ Application (e.g., unit-testing individual Active Objects and integration-testing groups of Active Objects)

[2] QP/C++ Framework use cases:

  • Framework Maintainer (actor) adapts/ports QP/C++ Framework to new CPU or 3rd-party RTOS/OS
  • Framework Maintainer (actor) traces QP/C++ Framework to fine-tune, optimize, debug the modifications
  • Framework Maintainer (actor) tests QP/C++ Framework to verify the modifications
  • Application Developer (actor) applies QP/C++ Framework by using its services

Portability & Configurability

A reusable architecture, like QP/C++ Framework, needs to be adaptable to a wide range of application areas and target hardware selections. For that, QP needs to be highly configurable. Whenever this requirements specification mentions "configurability", it explicitly specifies which of the following types of configurability is required:

Compile-Time Configurability

Compile-time configurability means that the specific configuration option (out of a given range of possibilities) is chosen at compile-time and cannot be changed later (e.g., at run-time). Compile-time configurability is typically used for:

  • Turning features on or off
  • Determining the size (and dynamic range) of various data types
  • Determining the maximum number of various objects in the QP/C++ Framework or QP/C++ Application
  • Determining the presence (or absence) of class members
Remarks
In C or C++, compile-time configurability is typically implemented with the preprocessor macros, but can also be achieved by the composition of the selected modules.

Run-Time Configurability

Run-time configurability means that the specific configuration option is chosen at run-time. Unlike compile-time configurability, run-time configurability has a finer granularity, usually on an object-by-object basis. It is typically used for:

  • Choosing a specific implementation of a class operation based on the object type (polymorphism)
  • Selecting features by calling or not calling the specific QP API
  • Selecting features by passing parameters to the specific QP API

About this DocumentActive Objects