In this article, we explore quantum platform (QP) frameworks and modelling tool. The framework can be used to produce highly-responsive and modular-embedded system applications. Design and implementation of real-time embedded software is so easy with the help of the QP modelling- and code-generation tool
Jai Sachith Paul
QP, from Quantum Leaps, is a family of open source frameworks that helps a user build efficient real-time embedded applications. The framework can completely replace the need for a traditional real-time operating system (RTOS) on a bare-metal single-chip microcontroller that controls the entire embedded system. The QP family consists of three frameworks: QP/C and QP-nano (written in C) and QP/C++ (written in C++).
Why quantum platform
The QP reveals itself before us as a better alternative to the RTOS in a single-chip microcontroller, controlling the embedded system application. Let us try to figure out the reasons for this.
No blocking. In an RTOS, we have counters, flags and other blocking mechanisms that are time-consuming in the sense that, when a program is blocked, it is not doing any work while waiting for an event. This also consumes a lot of memory space. In order to keep things simple, active objects are introduced into the QP framework by behavioural modelling specified by hierarchical state machine (UML state chart).The QP framework provides the active objects with the execution thread, queuing of events and event based timing services.
The elimination of blocks helps the program to have a smaller footprint in RAM (data space) as well as in ROM (code space). The scalability and efficiency is thereby increased considerably in a resource-constrained embedded system.
High-efficiency and better resource utilisation. The flow of program is controlled by asynchronous events initiated by user actions, such as a mouse click, sensor outputs or messages from other threads. This event-driven approach helps the programmer to express his event more directly, which, in turn, improves the efficiency of his work. Another advantage of using this scheme is that the CPU needs to be busy at the occurrence of the event only. This means, that, we have a better resource-utilisation and power-efficiency. No wonder the event-driven, quantum platform is ideal for single-chip microcontrollers in embedded system design.
Graphical modelling using QM
By knowing the advantages of decomposing the software into event-driven actors, a developer might wonder how the quantum platform could be used to implement real-time embedded software. In order to help them, the package comes with a really cool graphical modelling tool, QP modeler (abbreviated as QM). The QM helps you elaborate graphically UML state charts associated with active objects. While using this tool, you need not re-invent the software architecture from scratch. The modeller helps you reuse the active object framework provided by QP. This will, in turn, increase your productivity dramatically.
QM also features automatic generation of C/C++ code, depending upon the framework used. Automatic model verification is also done during code generation. The tool provides mechanisms to quickly switch between the code and model, so as to apply required changes to the model than to the code. The QP/C and QP-nano frameworks comply with most of motor industry software reliability association’s MISRA-C:2004 rules, while the QP/C++ framework complies with most of MISRA-C++:2008 rules.
Pre-emptive multitasking kernel. Users can go for the traditional RTOS for running the active-object model. But the QP framework provides a simple, superfast, non-blocking, run-to-completion (RTC) kernel. The kernel provides fully-pre-emptive multitasking using a single stack for all actor threads.
The pre-emptive kernel determines the scheduling policy where an RTC step can be pre-empted in order to execute another thread in the same processor. The suspended RTC step can later be resumed. There will be no concurrency issues as long as the pre-empting and pre-empted threads do not share the same resources.
Encapsulation for enhancing concurrency. Encapsulation involves packaging of data with operations into classes. It includes a mechanism for restricting access to some of the object’s components as well as a language construct that facilitates bundling of data with the methods (or other functions) operating on that data.
Even without any mutual exclusion mechanism, all private attributes of the active objects can be accessed only by its own thread. In order to ensure proper encapsulation, the resources are not shared. A dedicated active object becomes the manager and access of the resources by the rest of the system is by the events posted to this manager-active object.