QP/C++  7.3.3
Real-Time Embedded Framework
Loading...
Searching...
No Matches
Cooperative Run-to-Completion Kernel

Software TracingPreemptive Run-to-Completion Kernel

Theory of Operation

The Active Object model of computation requires the provision of an "execution context" only during the RTC (Run-to-Completion) processing. An Active Object that is merely waiting for event(s) does not need an "execution context" at all. This opens up possibility of executing Active Objects sequentially in a single thread (e.g., the main() function in C or C++).

QV is a simple cooperative, non-preemptive kernel that executes Active Objects to completion one RTC step at a time. After every RTC step, the QV kernel performs priority-based scheduling that selects the highest-priority Active Object that has an event to process. Due to naturally short RTC steps, the simple non-preemptive QV kernel is often adequate for many real-time systems.

Figure 07_01: QV scheduler operation

Please note that because the state machines always return to the QV scheduler after each RTC step, a single stack can be used to process all state machines (memory-friendly architecture).

The QV scheduler can also very easily detect when all event queues are empty, at which point it can call the idle callback to let the application put the CPU and peripherals to a low-power sleep mode (power-friendly architecture).

Given the simplicity, portability, and low-resource consumption, the QV scheduler is very attractive. It allows allows the developer to partition the problem into Active Objects and let these Active Objects cooperate to gain access to the CPU. The thread-level response of the QV scheduler is the longest RTC step in the whole system, but because event-driven active objects don't block, the RTC steps tend to be short (typically just a few microseconds). Also, often you can break up longer RTC steps into shorter pieces (multi-stage processing), by posting an event to self and returning ("Reminder" state pattern). The self-posted event then triggers the continuation of longer processing.

Remarks
Sometimes it is not practical to break up long RTC steps, and consequently the thread-level response of the simple QV kernel might be too slow. In this cases you need to use a preemptive kernel. The big advantage of preemptive kernel is that it effectively decouples high-priority thread from low-priority threads in the time domain. The timeliness of execution of high-priority thread is almost independent on the low-priority threads. But of course there is no such thing as a free lunch. Preemptive kernels open the whole new class of problems related to race conditions. So you need to be very careful about sharing any resources.

Requirements

REQ-QP-07_00

REQ-QP-07_00
QP Framework shall...
Description
TBD...

Software TracingPreemptive Run-to-Completion Kernel