Inspiration

An alarm that fires late is a failure. An alarm that fires too often is also a failure: alarm fatigue is a well-documented hazard on hospital wards, because staff learn to ignore a monitor that cries wolf. And the quietest failure of all is a monitor that keeps showing the last reading after a probe has fallen off. That combination of timing, restraint and honesty is exactly what a real-time operating system is for, so we built a bedside alarm engine on QNX 8.0.

What it does

Vigil reads vital-sign frames for every bed (heart rate, SpO2, respiration, blood pressure, temperature, consciousness, oxygen) over UDP, checks them, and raises alarms the way a safety-critical system should.

  • Priorities and delays. HIGH, MEDIUM and LOW alarms after the concepts of IEC 60601-1-8. A limit must stay violated for a few seconds before an alarm is raised, so one noisy sample never wakes a nurse, and the value must stay back in range before it is lowered, with hysteresis so a reading hovering on a limit cannot flicker.
  • NEWS2 early warning score. A patient who is slowly getting worse is flagged by the score before any single value crosses its own limit (in the bundled deterioration scenario).
  • Honest about faults. A probe that falls off, or a bed that goes silent, raises a technical alarm and the affected value stops being judged. The stale number is never shown as if it were current.
  • Audio pause that cannot hide anything. It silences the sound for a fixed time; the visual alarm stays.

It is shown three ways: a quiet bedside dashboard, plain files under /dev/vigil, and a live feed driven by kernel pulses.

How it uses QNX 8.0

  • Timer pulse and a SCHED_FIFO engine (src/qnx/vigild.c): the alarm engine wakes on a kernel timer pulse.
  • Message passing as the only synchronisation (vigild.c, ipc.c, vigil_ipc.h): the engine owns all state with no locks. A lower-priority ingest thread decodes the network feed and MsgSends one message per valid frame, so a flood of garbage cannot delay the engine.
  • Secure events (tools/vigil_watch.c): a nurse-station client registers a pulse with MsgRegisterEvent and the engine fires it with MsgDeliverEvent when an alarm changes. No polling, and only the daemon can trigger it.
  • Resource manager (src/qnx/resmgr.c): cat /dev/vigil/alarms, and echo "hr_high_med 110" > /dev/vigil/config changes a limit live; an invalid limit is rejected.
  • Priority-inheriting mutex, slog2, mlockall for bounded readers, an audit trail of every alarm, and no page faults.

How we built it

The decision logic (frame decoding, NEWS2, the alarm engine) is portable C11 with no allocation and no QNX dependency, so the same sources run in 106 unit checks on a PC and on QNX. A simulator generates synthetic patients (a gradual decline, an acute desaturation, a probe fault, a silent bed, a busy ward) and 20 regression scenarios assert what a clinician would expect. The QNX layer is a thin set of threads around that core. Everything in the video was captured live from a QNX SDP 8.0 VM under QEMU.

Challenges and what running on the target taught us

Running the host tests on the target exposed a real platform difference: on QNX 8.0, strtod("36.8") returns a value one ulp above the compiler literal, so an exact comparison that passes on a PC failed on the device. We now normalise every vital sign to one decimal, so decisions are identical everywhere, and kept the test as a guard. Capturing the demo also caught a stale read of /dev/vigil/config right after a change, now fixed. Other lessons: alarms need hysteresis in value and in time or they flicker; technical alarms must end the moment their cause does, while physiological alarms should wait.

What is next

Serial and HL7 input, a nurse-call integration through the secure-event channel, QNX security policies for the daemon, and a Raspberry Pi 5 build with a real SpO2 sensor.

Code and tutorial

Repository (MIT): https://github.com/tapaderuza/vigil-qnx . Build and run: README. Tutorial: docs/CODELAB.md. Run log on QNX: docs/QNX_RUN.md.

Safety note: illustrative software with synthetic patients. It is not a medical device and must not be used for patient care.

Built With

  • c
  • healthcare
  • html
  • pytest
  • python
  • qemu
  • qnx
  • qnx-neutrino
  • real-time
Share this project:

Updates

Submission history