Inspiration

QNX runs in the markets the organizers themselves name on the hackathon page: medical devices, factory floors, trains, robots, and more than 275 million vehicles. In those systems the pitch is not only that the code runs, but exactly when it runs. A high-priority thread can still miss its deadline for reasons that only show up under real scheduling: a POSIX semaphore that does not inherit priority, a job that is simply longer than its period, or — on a microkernel — a client blocked in SEND/REPLY behind a server or a resource manager that is not ready.

The evidence is in the kernel trace, but a tracelogger capture decoded with traceprinter is tens of thousands of events long (our captures have 18,000 to 141,000 events). Reading that by hand is slow, so the bug is often found late — in the field, not on the host. We wanted the tooling we always wished existed for QNX 8.0: one command that finds the fault, proposes a concrete fix, applies it, and proves on the same QNX guest that the fix worked.

What it does

qtc run ./priority_inversion (or ./missed_deadline, ./ipc_deadlock, ./ipc_prio_inversion, ./slow_resmgr, ./pulse_drop) is a host tool for QNX SDP 8.0:

  1. Boots or reuses a QNX 8.0 x86_64 guest in QEMU and builds the demo with qcc.
  2. Uploads the binary, runs it under tracelogger -w (wide mode, so thread events carry priority), copies the .kev back and decodes it with traceprinter.
  3. Analyzes the real trace with rule-based detectors: priority inversion (THSEM / THMUTEX), deadline misses (from USREVENT strings emitted with trace_logf()), pid-scoped mutex/semaphore contention, and interrupt occupancy.
  4. In the same decoded trace, looks at QNX microkernel IPC: MsgSend / MsgReceive / MsgReply and the thread states THSEND / THREPLY / THRECEIVE; deadlock cycles in the SEND/REPLY wait-for graph; message-passing priority inversion (including _NTO_CHF_FIXED_PRIORITY channels); a slow resource manager that queues a high-priority client; and pulses refused by an exhausted private pulse pool (MsgSendPulse() returning EAGAIN).
  5. Proposes a concrete source fix, applies it to a copy of the demo, rebuilds with qcc, re-runs on the same guest and captures a second .kev.
  6. Writes timeline.html (per-thread SVG lanes with the finding window and evidence line numbers) and SUMMARY.md with before/after numbers computed from guest cycle timestamps (TRACE_CYCLES_PER_SEC).

Real results on QNX 8.0.0 in QEMU (committed captures, testdata/real/runs/):

Demo Before After the fix
priority_inversion High (tid 3, prio 40) blocked 1532.579 ms in THSEM while Low (prio 10) held a semaphore and Mid (prio 15) ran pthread_mutex with PTHREAD_PRIO_INHERIT: 401.660 ms in THMUTEX (the remaining HOLD_MS=400 hold); inversion finding 1 → 0. The after report may still list that 401.660 ms wait as mutex_contention (above the 1000 µs threshold); that is the expected hold, not a failed fix
missed_deadline 4 deadline_miss findings, longest job 19.041 ms vs a 10.000 ms period HEAVY_MS=4: 0 findings, program reports 0 misses
ipc_prio_inversion ipc_priority_inversion=1: prio-40 client blocked 1605.329 ms in MsgSend (SEND-queued 1503.770 ms + REPLY 101.559 ms); server stayed at prio 10 while the prio-15 thread ran 1497.547 ms 191.356 ms (queued 89.924 ms + served 101.432 ms); inversion finding gone. The remaining ipc_send_blocked is honest head-of-line time behind Low's in-progress 100 ms request. Delta 1413.973 ms
ipc_deadlock ipc_deadlock=1: 2-thread SEND/REPLY cycle held 1500.421 ms; worst client MsgSend 1502.403 ms no finding, 0 cycles; worst client MsgSend 3.823 ms
slow_resmgr ipc_send_blocked=1: prio-30 client SEND-queued behind a prio-10 logger, worst 197.205 ms, mean 174.060 ms no finding; worst 1.116 ms, mean 0.876 ms
pulse_drop pulse_dropped=1: 96 of 129 MsgSendPulse() refused (EAGAIN), 33 received, peak backlog 32, at most 8 queued pool sized to 64 from the measured peak: 0 refused, 129/129 received

The demo video shows a fresh run of priority_inversion and missed_deadline on the same day: 1528.546 ms → 401.838 ms (delta 1126.709 ms), and 4 findings with the longest job at 19.171 ms → 0. Numbers move by a few milliseconds between runs; none are simulated. The committed IPC figures above are from the same guest later that evening (TRACE_CYCLES_PER_SEC=2397190010, 21:23–21:24 Europe/Madrid).

Explanations are rule-based. An optional local Ollama model can add a paragraph if it is already installed; the tool never calls a paid API. This is not an AI-model project and we do not claim it is.

How we built it

  • QNX version / target / toolchain: QNX SDP 8.0 (com.qnx.qnx800, patch 8.0.6) installed with QNX Software Center 2.0.4 under the QNX Everywhere non-commercial license; mkqnximage --type=qemu --arch=x86_64 image; QEMU 10.0.13 with TCG, -cpu max,vendor=GenuineIntel, 1 vCPU, 2 GB RAM; qcc 12.2.0, target gcc_ntox86_64.
  • QNX-specific pieces (for the bonus — details in the evidence section below): tracelogger wide-mode kernel tracing (.kev), traceprinter, user trace events through trace_logf() that arrive as USREVENT, QNX priority-inheritance semantics (PTHREAD_PRIO_INHERIT on mutexes vs. semaphores that do not inherit), MsgSend / MsgReceive / MsgReply and the kernel states THSEND / THREPLY / THRECEIVE, message-passing priority inheritance (default vs _NTO_CHF_FIXED_PRIORITY), resmgr_attach() resource managers with iofunc_attr_unlock() and a receive-thread pool, MsgSendPulse() / ChannelCreatePulsePool(), qcc cross-compilation, mkqnximage guest image, real-time scheduling classes (SCHED_RR threads at priorities 10 / 15 / 40 and a periodic 10 ms job).
  • Host side: Python 3.11, standard library only. qemu_target.py drives QEMU + SSH, parser.py reads traceprinter text, detectors/ holds the rule-based detectors (detectors/ipc.py is the microkernel IPC model), fixer.py produces and applies fixes to a source copy, runloop.py is the detect → fix → prove loop, html_report.py writes the timeline.
  • Demos: target/priority_inversion.c (Low/Mid/High threads sharing a semaphore), target/missed_deadline.c (10 ms periodic job with an 18 ms heavy job every 8th period), target/ipc_deadlock.c, target/ipc_prio_inversion.c, target/slow_resmgr.c, target/pulse_drop.c.
  • Evidence in the repo: real .kev and traceprinter output for every before/after capture under testdata/real/, the guest logs, the fixed sources, docs/QEMU_SETUP.md, docs/TRACE_PIPELINE.md, docs/CODELAB.md, 31 unit tests (11 of them for the IPC detectors, run against the real captures): PYTHONPATH=src python3 -m unittest discover -s tests.

Challenges we ran into

  • KVM did not work on our host. Official mkqnximage --run wants KVM; on this Debian 13 box the KVM vCPU thread segfaulted in every combination we probed, so the supported path is TCG. A plain qemu64 CPU under TCG aborted in startup-x86; -cpu max,vendor=GenuineIntel boots to SSH in about 12 s. Debian 13 is not an official SDP host; it worked, but it is unsupported.
  • A false positive found by our own re-run. On a fresh capture the detector flagged an inversion on the fixed demo because a daemon from another process (io-sock, prio 21) ran while Low was asleep holding the mutex. We changed the detector to count only threads from the same process as the blocked thread, and checked the real capture into the repo as a regression test (testdata/real/regress/; the test fails without the fix).
  • Lost user events. During the first overrun burst tracelogger can drop some USREVENTs. In the committed capture the program logged 5 misses while the trace had DEADLINE_MISS events for 3 of them (a fourth finding comes from a late DEADLINE_START); we report what the trace proves, not the program's own count.
  • Priority cannot fix everything. Raising a thread's priority does not make 18 ms of work fit in a 10 ms period, so the copilot shortens the work instead of "boosting" it.
  • Message-priority inheritance does not remove head-of-line blocking. After dropping _NTO_CHF_FIXED_PRIORITY, the prio-40 client still waited 191.356 ms (89.924 ms queued + 101.432 ms served) behind Low's in-progress request; a single receive thread must finish the work it holds. The same thing is the whole slow_resmgr case.
  • More resource-manager threads alone are not enough. With 3 threads but the iofunc attribute still locked around the slow read, the prio-30 client's worst read was still 180.321 ms (testdata/real/probes/slow_resmgr_threads_without_attr_unlock.log). The fix also calls iofunc_attr_unlock() around the slow part.
  • The pulse detector only trusts the EAGAIN path visible in the trace (KER_EXIT MSG_SEND_PULSE ret_val:-1 errno:11). A SIGEV_SEM custom event on a dry pool SIGKILLed the owner in our run (exit 137); we did not pin down why the custom event was not honoured, so we do not claim that path.

Accomplishments that we're proud of

  • A closed detect → fix → prove loop that ends in a second real kernel trace, not a screenshot.
  • Every number in the README, the video and this text comes from a tracelogger capture on QNX 8.0 (cycle timestamps), with the .kev files in the repo.
  • The tool found a bug in itself on a real re-run, and the fix shipped with a regression test.
  • One command, no third-party Python dependencies, MIT licensed.
  • Microkernel IPC, measured on the same guest: message-priority inversion 1605.329 ms → 191.356 ms (delta 1413.973 ms); a 1500.421 ms SEND/REPLY deadlock gone, worst client MsgSend 1502.403 ms → 3.823 ms; a slow resource manager 197.205 ms → 1.116 ms; 96 of 129 pulses refused → 0 refused, 129/129 received.

What we learned

  • On QNX, mutexes propagate priority to the holder and semaphores do not. A trace can show that difference clearly: 1528–1533 ms of waiting versus about 401 ms.
  • Wide-mode tracelogger events carry thread priority, which is what makes inversion detectable from the trace alone.
  • trace_logf() user events turn an application's own notion of "deadline" into something a host tool can analyze.
  • A tool that proposes a fix must also re-measure; otherwise it is only a lint.
  • Client-driven priority inheritance through messages is on by default: in every IPC capture the server switches to the sender's priority when it receives. _NTO_CHF_FIXED_PRIORITY switches that off — the server stayed at priority 10 for the whole 1.6 s before the fix. A busy server is also boosted when a higher-priority client SEND-blocks on it (after-trace lines 17173–17174: the server is THRUNNING at priority 40 mid-way through Low's request). Inheritance still leaves head-of-line blocking; pulses are lost when a private pulse pool runs dry and MsgSendPulse() returns EAGAIN, not because timer pulses are overwritten.

What's next

  • Multi-core targets and real hardware (Raspberry Pi 4 quick-start image) to compare against QEMU/TCG.
  • Run in CI: capture, analyze and fail a build on a regression.
  • Tighter fixes (patches against the user's source, not just a demo copy).

Evidence of QNX 8.0 use (include at the end of the story or in a clear block judges can scan)

  • Build/run: README.md → "QNX version, target, toolchain" and "Build and run, step by step"
  • QNX code: target/priority_inversion.c, target/missed_deadline.c (PTHREAD_PRIO_INHERIT, trace_logf, SCHED_RR); target/ipc_deadlock.c, target/ipc_prio_inversion.c, target/slow_resmgr.c, target/pulse_drop.c
  • Target launch and capture: src/qnx_trace_copilot/qemu_target.py (tracelogger -w, qcc, SSH into the guest)
  • Real traces: testdata/real/runs/*/{before,after}/*.kev and *.traceprinter.txt
  • Demo: video, qtc run on the live QNX 8.0.0 guest (uname -a → QNX noname 8.0.0 … x86pc x86_64)

Evidence of QNX-specific technologies (bonus)

The official bonus asks for creative, impactful, or sophisticated use of unique QNX capabilities, “including but not limited to native message passing, resource managers, microkernel architecture, startup and boot customization, real-time services, and security policies.” Here is where each claim lives. We do not claim startup/boot customization or security policies.

Official capability What this project does Where to verify
Real-time services Wide-mode tracelogger + traceprinter; SCHED_RR and priorities; PTHREAD_PRIO_INHERIT vs semaphores that do not inherit; deadline USREVENTs via trace_logf() qemu_target.py, target/priority_inversion.c, target/missed_deadline.c, testdata/real/runs/
Microkernel architecture Analysis of a real Neutrino kernel trace (.kev), including thread blocking states the kernel actually emits (THSEM, THMUTEX, THSEND, THREPLY, THRECEIVE, …) testdata/real/runs/*/*.kev, parser.py, detectors/ipc.py, timeline.html
Native message passing Detectors for MsgSend / MsgReceive / MsgReply deadlock cycles and priority inversion through messages. Deadlock cycle 1500.421 ms → 0 findings, worst client MsgSend 3.823 ms; inversion 1605.329 ms → 191.356 ms (delta 1413.973 ms) detectors/ipc.py, target/ipc_deadlock.c, target/ipc_prio_inversion.c, testdata/real/runs/ipc_deadlock/, testdata/real/runs/ipc_prio_inversion/
Resource managers ipc_send_blocked on a single-threaded resmgr_attach() path; fix adds receive threads and iofunc_attr_unlock() around slow work. Worst 197.205 ms (mean 174.060 ms) → no finding, worst 1.116 ms (mean 0.876 ms) target/slow_resmgr.c, testdata/real/runs/slow_resmgr/
Pulses (microkernel IPC) pulse_dropped on MsgSendPulse() EAGAIN when a private pulse pool runs dry. 96 of 129 refused, 33 received, peak backlog 32 / max queued 8 → pool sized to 64: 0 refused, 129/129 received target/pulse_drop.c, testdata/real/runs/pulse_drop/

Built With

  • c
  • github
  • html-svg
  • mkqnximage
  • msgreceive
  • msgreply
  • msgsend
  • msgsendpulse
  • neutrino
  • posix-threads
  • python
  • qcc
  • qemu
  • qnx
  • qnx-neutrino-rtos
  • qnx-sdp-8.0
  • resource-manager
  • rtos
  • trace-logf
  • tracelogger
  • traceprinter
Share this project:

Updates

Submission history