Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

QCrit — Mixed-Criticality Runtime Governor for QNX Neutrino 8.0

QCrit is an autonomous, low-overhead runtime governor designed for safety-critical mixed-criticality systems running on QNX Neutrino RTOS 8.0 (targeting x86_64).

It monitors execution time trajectories using EWMA and linear trend prediction, dynamically degrades non-critical workloads before deadlines are missed, preserves strict immunity for safety-critical tasks, and coordinates upstream quality changes across functional dependency graphs.


Key Capabilities

  1. Predictive Slack Estimation:

    • Tracks per-task execution histories and computes EWMA with linear trend extrapolation.
    • Detects upcoming deadline violations before they occur, providing early-warning headroom to shed CPU contention.
  2. Mixed-Criticality Hierarchy & Degradation Reasoning:

    • Tasks are assigned static criticality tiers:
      • CRITICAL (Tier 3): e.g., safety_controller — Never degraded, immune to resource reclamation.
      • HIGH (Tier 2): e.g., adas_perception — Degrades only if critical tier is at risk.
      • STANDARD (Tier 1): e.g., infotainment — Primary target for shedding CPU load.
      • LOW (Tier 0): e.g., diagnostics — First to be suspended under system stress.
    • Modes supported: FULL (0), REDUCED (1), MINIMAL (2), SUSPENDED (3).
  3. Functional Dependency Notifications:

    • When an upstream workload degrades (e.g., perception quality drops), QCrit sends a QCRIT_PULSE_DEP_CHANGED pulse to downstream consumers (e.g., safety controller) so they can switch to conservative fallback posture without cascading system panic.
  4. Microkernel-Native IPC & Zero-Lock Dispatch:

    • Uses native QNX Neutrino channels, connection IDs, and non-blocking real-time pulses (MsgSendPulse).
    • Senders authenticated via ConnectClientInfo on 64-bit QNX 8.0.
  5. Autonomous Health Monitoring & Flight Recorder:

    • Periodic heartbeat verification detects hung or crashed workloads.
    • Lockless in-memory circular ring buffer logs all lifecycle events, mode changes, and verification passes for post-incident diagnostics.

Directory Structure

QCrit/
├── QNX/
│   ├── Qcrit_vm/                 # QNX Momentics IDE Project (x86_64 target)
│   │   ├── Makefile              # Multi-binary QNX Makefile (qcc + ntox86_64-gcc-ar)
│   │   ├── .project / .cproject  # Eclipse CDT / Momentics project metadata
│   │   ├── build/x86_64-debug/   # Output directory for all 8 binaries + client library
│   │   └── src/
│   │       ├── include/qcrit/    # Public headers (types.h, protocol.h, client.h, config.h)
│   │       ├── daemon/           # Governor core (main, registry, predictor, reasoner, etc.)
│   │       ├── lib/              # Workload client library (client.c)
│   │       ├── workloads/        # Mixed-criticality test tasks (safety, adas, info, diag)
│   │       ├── tools/            # Utilities (stress_injector, fault_injector, qcrit_dump)
│   │       └── demo/             # run_demo_vm.sh & analyze_results.py
│   ├── vm1/                      # Target connection profile (VirtualBox QNX 8.0 VM)
│   └── vm2/                      # Secondary target connection profile
├── daemon/                       # Original daemon source tree
├── include/                      # Original public API headers
├── lib/                          # Original client library source tree
├── workloads/                    # Original workload source trees
├── tools/                        # Original tools source trees
├── demo/                         # Demo runner scripts and evaluation utilities
├── tests/                        # Offline host unit tests (predictor & dependency graph)
├── Makefile                      # Root Makefile for command-line builds
└── common.mk                     # Root toolchain configuration

Building

Method A: Via QNX Momentics IDE (Recommended)

  1. Open QNX Momentics IDE with workspace set to d:\Projects\QCrit\QNX.
  2. Right-click the Qcrit_vm project in the Project Explorer.
  3. Click Build Project.
  4. All 8 executables and libqcrit_client.a will be generated in QNX/Qcrit_vm/build/x86_64-debug/.

Method B: Via Command Line (QNX SDP 8.0)

From Command Prompt or PowerShell:

call C:\Users\<user>\qnx800\qnxsdp-env.bat
make -C d:\Projects\QCrit\QNX\Qcrit_vm clean all

Running the System

1. Interactive Testing in Momentics IDE

  1. Start the Governor Daemon:
    • In Momentics, right-click build/x86_64-debug/Qcrit_vm ➔ Run As ➔ QNX C/C++ Application.
    • Select your target VM (vm1).
    • The daemon console will display:
      [daemon] listening on 'qcrit'
      
  2. Start Workloads:
    • While Qcrit_vm is running, right-click and launch adas_perception or safety_controller.
    • The workload connects to the governor, authenticates, and begins periodic execution.
    • Switch between process consoles using the Display Selected Console (🖥️▾) icon in Momentics.

2. Automated Closed-Loop Demo (run_demo_vm.sh)

Copy the built binaries and run_demo_vm.sh to /tmp/qcrit/ on the QNX VM, then run:

cd /tmp/qcrit
chmod +x run_demo_vm.sh
./run_demo_vm.sh

The script executes 3 phases:

  • Phase A: Measures deadline misses under contention without QCrit.
  • Phase B: Runs under QCrit supervision — observes predictive degradation of infotainment and protection of safety_controller.
  • Phase C: Injects a task crash via fault_injector and monitors autonomous recovery.

3. Real-Time Split-Screen Dashboard (qcrit_dashboard)

Launch the terminal dashboard directly on the target (via Momentics Terminal Console or SSH):

# Read-Only monitoring
/tmp/qcrit/qcrit_dashboard

# Interactive Demonstration Mode (enables hotkeys)
/tmp/qcrit/qcrit_dashboard --demo

Dashboard Features:

  • Split-Screen Layout:
    • Upper Panel: Active task table showing criticality tiers, dynamic operating modes (🟢 FULL, 🟡 REDUCED, 🔴 SUSPENDED), heartbeat freshness, period/deadline, and graphical predicted slack bar (+12.4ms [====| ]).
    • Lower Panel: Live-scrolling Flight Recorder events color-coded by severity (risk detections, degradations, recoveries, and health watchdog restarts).
  • Interactive Hotkeys (in --demo mode):
    • s : Launch stress_injector (8s burst) to induce CPU contention and watch lower-tier workloads degrade live on screen while critical tasks stay protected.
    • k : Send SIGKILL to an active non-critical workload to test QNX health watchdog timeout detection and auto-recovery.
    • p : Pause / resume flight recorder stream to inspect event details.
    • q : Clean exit.
  • Fail-Safe Resilience: Uses 250ms QNX TimerTimeout() to prevent blocking if the daemon is loaded, and includes an auto-reconnect engine if the daemon is restarted.

4. Flight Recorder Inspection (CLI Dump)

Query live telemetry events recorded in the daemon's ring buffer:

/tmp/qcrit/qcrit_dump --last 50

5. Telemetry Analysis (CLI)

Analyze the generated timing logs (qcrit_*.log) on your host machine:

python analyze_results.py --log-dir /path/to/logs

6. Interactive Scheduling Trace Viewer (FastAPI Web App)

Launch the real-time scheduling trace viewer and flight recorder dashboard (runs on Host or Raspberry Pi):

# Run with demo logs
python run_viewer.py --demo

# Or run against target / VM logs
python run_viewer.py --log-dir /path/to/logs --port 8000

Open http://localhost:8000 (or http://<pi-ip>:8000) in your browser to inspect:

  • Multi-Lane Gantt Scheduling: Real-time mode degradation across tiers (FULL, REDUCED, MINIMAL, SUSPENDED).
  • Execution Time vs. Hard Deadline: Measured execution ($C_i$) vs. deadline ($D_i$) with smoothed EWMA extrapolation and slack warning margins.
  • Real-Time Live Simulation: Interactive playback with contention burst injection and auto-recovery.
  • A/B Comparative Evaluation: Side-by-side verification proving 0 deadline misses under QCrit governance.
  • Flight Recorder Stream: Real-time event feed with filterable severity tags.

License & Attribution

Designed for mixed-criticality real-time operating systems under QNX Neutrino 8.0.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages