Execution Model
The stack utilizes a multi-tasking execution model managed by the VAIOS (Vayu Input/Output System) real-time kernel. This model ensures that high-frequency control loops, asynchronous communication, and background maintenance tasks coexist on a single microcontroller while satisfying strict real-time constraints.
Task Scheduling and Priorities
The system organizes functionality into discrete tasks, each assigned a priority level and an execution frequency. VAIOS employs a priority-based preemptive scheduler, ensuring that critical tasks can interrupt lower-priority operations to meet timing guarantees.
The task hierarchy is structured into three primary tiers:
Tier 1: High-Priority Control (Priority 2): The
bmx160_readtask resides here. Since state estimation and control accuracy depend on precise sensor timing, sensor acquisition is given the highest precedence to minimize jitter.Tier 2: Real-Time Processing (Priority 1): This tier contains the Control Loops (Angle and Rate PID) and the Motor Output task. These tasks run at fixed intervals (e.g., 400 Hz to 1 kHz) and consume the data provided by Tier 1.
Tier 3: Asynchronous Utilities (Priority 0): Lower-priority tasks such as
comm_processor(telemetry),heartbeat, andlogger. These tasks utilize the remaining CPU cycles to handle non-critical data exchange and system monitoring.
Execution Timing Diagram
Figure 3.5 illustrates the interleaved execution of high and low priority tasks over a single control cycle.
Deterministic Guarantees
By utilizing a hardware-backed DWT (Data Watchpoint and Trace) timer and the VAIOS scheduler, the system achieves sub-microsecond jitter for task wakeup. This determinism is critical for the stability of the inner PID loop, where even a few milliseconds of variance in the sampling interval () can lead to oscillations or loss of control during aggressive maneuvers.