Technology

Why it runs on QNX

A late piston stroke is a bruised chest or a breath on the downstroke. A crashed classifier must not take the piston with it. Those are operating system problems, and QNX was built for them.

Architecture

Small processes, clear jobs

Each part is its own QNX process with its own priority, user and security type. They talk through message passing and shared memory that never blocks the control loop.

PRIORITY 60

elvrekd

The safety authority. Wakes every millisecond, runs the state machine and the independent monitor, and is the only writer to the actuators.

PRIORITY 55

elv-plant

Stands in for the hardware today: actuator, chest, load cell, capnograph, ECG and charger. Owns the hardware watchdog.

SUPERVISOR

elv-super

Restarts the advisor when it dies or goes quiet. Never restarts the safety process.

PRIORITY 10

elv-advisor

The rhythm classifier. Unprivileged, abilities locked, reads only a copy of the ECG, writes only advice.

PRIORITY 12

elv-telemetry

Streams status to the crew console over the network. Has no way to write into the safety process.

CREW

elv-ctl

Start, stop, shock, mode and transport commands from the crew, through a device only root may open.

The fence

The AI may suggest. QNX decides who may touch.

  • The advisor drops to its own user and locks the abilities it could use to climb back: priority, spawn, fork, setuid, physical memory and I/O.
  • The piston and shock devices are read only. The operator device is root only. The hardware memory is root only.
  • An enforced QNX security policy runs every process under its own type. Advice goes through a small gate process, and the advisor may connect to the gate and nothing else. Kept as root under its type, the advisor is still refused the piston and the shock line by the kernel itself (5 of 7 attacks refused as root, 7 of 7 as designed, 0 of 7 without the type).
  • Its worst case is to talk the controller out of one pre-charge. The next two minute boundary is always checked.
  • elv-advisor -a tries every forbidden path and prints the refusals. It is a test case on the target.

Piston, charger, shock line

Written only by elvrekd, through shared memory owned by root.

advice only, through its own channel

elv-advisor

Unprivileged user, locked abilities, read only ECG.

State machine

Eight states, one owner

The highlighted state moves as the recorded run plays on the evidence and replay pages. Here it walks through a typical rescue.

Idle→ Compress→ Vent gap→ Shock window→ Return of circulation→ Fault retract→ Safe hold→ Stopped

Hands on

Compress is the only hands-on state. Chest compression fraction counts the time spent here against the time CPR is needed.

Hands off, on purpose

The shock window and the 30:2 breath gap are the only planned pauses, and both have hard time limits.

Hands off, for safety

Return of circulation, fault retract and safe hold all park the piston at full recoil.

QNX features in use

Native, not ported

Timer pulses on a private channelThe 1 ms control tick, received at a fixed priority with MsgReceivePulse.
Resource managers/dev/elvrek/status, advice, operator, piston and shock, served with iofunc permission checks.
Message passing priority inheritanceA flooding advisor at priority 10 is served at priority 10 and cannot delay the loop at 60.
procmgr_abilityThe safety process and the advisor each deny and lock what they no longer need.
Security policy typesOne type per process; the advice path gets its own channel type with allow_attach.
System Launch and MonitorStarts the stack in order, pins the safety process to its own CPU, and marks it repair none.
slog2Faults and forced retracts are logged without file I/O in the control loop.
mkqnximageBuilds the bootable QEMU image with the stack and the fault suite on it.

Build it yourself

Target: QNX SDP 8.0, x86_64 in QEMU or aarch64 on a Raspberry Pi 5. Toolchain: qcc. The same safety core also builds on any Linux machine for the host tests.

Open the repository
# host tests
make test
# QNX target
source ~/qnx800/qnxsdp-env.sh
make -C qnx
qnx/build-image.sh
# on the target, as root
sh /data/elvrek/fault_suite.sh