A deterministic Wi-Fi spectrum analyzer on QNX Neutrino
Scanning nearby networks, scoring channel congestion and recommending a channel, with real-time scheduling guarantees on a Raspberry Pi 4.
- role
- Solo
- type
- Personal · RTOS
- platform
- RPi 4 (BCM2711, aarch64)
- stack
- C · QNX · POSIX · CMake
Why
After a semester of real-time systems in theory, I wanted something that put the concepts into practice. QNX Neutrino is a microkernel RTOS used in automotive, medical and industrial systems, and the Pi 4 has a QNX BSP, so it's an accessible target without an expensive evaluation board.
Architecture
A producer–consumer pair shares a scan-results buffer. The scanner is high-priority and I/O-bound; the analyzer is lower-priority and compute-bound.
// Scanner: SCHED_FIFO at priority 15
pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
param.sched_priority = SCANNER_PRIORITY;
pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
pthread_attr_setschedparam(&attr, ¶m);
pthread_create(&scanner_tid, &attr, scanner_thread, &shared);Key decisions
Without PTHREAD_EXPLICIT_SCHED a thread inherits its parent's policy, which silently defeats the priorities.
The shared buffer's mutex uses PTHREAD_PRIO_INHERIT, so the scanner can't be stuck behind the lower-priority analyzer (unbounded priority inversion).
Heap allocation time depends on fragmentation, so time-critical paths use only preallocated memory.
Results
Channel recommendations from live scans, with the scanner's timing unaffected by analysis load.