QP/C: A Lightweight Open Source Real-Time Embedded Framework

QP/C, a lightweight and open source real-time embedded framework (RTEF), provides powerful tools for building modern embedded software. It is based on the active object (Actor) model and has won widespread acclaim in the embedded systems development field due to its efficiency, safety, and ease of use. This article will delve into the key features, usage methods, and licensing models of the QP/C framework.

Core Advantages of QP/C: Active Object Model

The core idea of QP/C is the active object model, which is fundamentally different from traditional shared state-based concurrency models. Traditional models rely on explicit mutexes and blocking RTOS threads, which are prone to deadlocks and race conditions. The active object model enhances the safety of concurrent programming in the following ways:

  • Data Isolation: Each active object has its own independent data space, avoiding data races.
  • Asynchronous Communication: Active objects communicate asynchronously through events, preventing thread blocking.
  • Event Loop: The main loop of an active object is an event processing loop that sequentially handles events, avoiding concurrency conflicts within a single active object thread.

This architecture not only enhances safety but also provides a higher level of abstraction, facilitating the application of hierarchical state machines and code generation.

Hierarchical State Machines: Simplifying Complex Logic

The operational behavior of active objects is defined by hierarchical state machines (UML state diagrams). QP/C supports manually written C language state machine code as well as automatic code generation using the free QM modeling tool. This allows developers to more easily handle complex system logic, improving code readability and maintainability.

Built-in Real-Time Kernels: Flexible Options

QP/C does not rely on traditional RTOS; it includes multiple built-in real-time kernel options, such as:

  • QV: Non-preemptive kernel.
  • QK: Preemptive non-blocking kernel.
  • QXK: Preemptive dual-mode kernel with more comprehensive features.

Additionally, QP/C provides native ports and sample programs for mainstream CPUs (such as ARM Cortex-M series), allowing developers to quickly get started.

Compatibility: Seamless Integration with Traditional RTOS and Operating Systems

QP/C is not limited to its built-in kernels; it can also seamlessly integrate with other popular RTOS (such as ThreadX, embOS, FreeRTOS, uC/OS-II, Zephyr) as well as embedded Linux (POSIX) and Windows operating systems, offering greater flexibility.

Licensing Model: Dual Options of Open Source and Commercial

QP/C adopts a dual licensing model, supporting both open source (GPLv3) and commercial licenses. Under the open source license, developers can freely use and modify the code, but must comply with the GPL agreement and release modified code as open source. The commercial license allows developers to use QP/C without disclosing the source code, suitable for projects with high confidentiality requirements. It is important to note that some components (such as QS, QXK) have been removed from the open source version and are only available under the commercial license.

Getting QP/C: Convenient Access

It is recommended to download QP/C using the QP-bundle, which includes the QP/C framework, QM modeling tool, and QTools toolkit, making it easy for developers to get started. In addition, Quantum Leaps provides a wealth of learning resources, including tutorials, videos, and application notes, to help developers quickly master the use of QP/C.

Wide Application: Proven Over Time

QP/C has undergone over 20 years of continuous development, with more than 400 commercial users and numerous open source users, widely used in various electronic products, from implanted medical devices to complex weapon systems, proving its stability and reliability.

Conclusion

QP/C is a powerful, flexible, and time-tested real-time embedded framework. It is based on the active object model, employs hierarchical state machines, and offers multiple kernel choices and good compatibility. Whether opting for open source or commercial licensing, QP/C can meet the needs of different developers and is an ideal choice for building safe and reliable embedded systems.

Project address: https://github.com/QuantumLeaps/qpc

Leave a Comment