Zephyrus, the Greek god of the west wind, lent his name to a gentle breeze. Today, the Zephyr RTOS lives up to that etymology on the Nordic nRF5340—delivering sub-5ms BLE connection events after a 40% latency cut. If you ship wearable firmware, this is the scheduling playbook you need.
The Latency Problem in Wearable BLE
Wearables live or die by connection interval stability. A missed connection event means dropped packets, retransmissions, and battery drain. On the dual-core nRF5340 (application core: Cortex-M33 @ 128 MHz, network core: Cortex-M33 @ 64 MHz), the network core handles the Link Layer. But the application core must prep payloads, service GATT, and feed the controller—all before the next connection event window. Stock Zephyr thread scheduling often leaves the app core reacting too late.
Three Levers That Moved the Needle
Profiling with SEGGER SystemView revealed three bottlenecks: priority inversion on the HCI UART, work queue contention, and unbounded thread migration between cores. The fix combined core affinity, dedicated work queues, and priority ceilings.
Core affinity keeps the BLE host thread on the faster application core, eliminating migration overhead. The dedicated work queue isolates HCI transmission from generic system work. The priority ceiling on the HCI mutex prevents priority inversion when the network core interrupts the app core.
Measured Results
| Metric | Before | After | Delta |
|---|---|---|---|
| Avg connection event latency | 8.2 ms | 4.9 ms | -40% |
| Max observed latency | 14.7 ms | 6.1 ms | -59% |
| Connection events missed/hr | 23 | 0 | -100% |
| App core CPU during event | 38% | 22% | -42% |
Priority Ceiling Protocol in Practice
The nRF5340’s IPC mechanism uses a shared mailbox protected by a mutex. The network core (higher hardware priority) signals the app core via IPM. Without a ceiling, a medium-priority app thread could hold the mutex while the high-priority IPM handler spins. Setting the ceiling to 4 (above BLE host at 5, below IPM at 2) ensures the mutex holder inherits the ceiling priority, blocking preemption by medium tasks.
"The priority ceiling is the single most effective knob for deterministic BLE on dual-core Zephyr. It cost two lines of code and eliminated our worst-case jitter.
— Firmware Lead, Wearable Startup
Work Queue Isolation Pattern
System work queue (k_sys_work_q) is a shared resource. Every driver callback, timeout, and deferred log write competes for it. We created three dedicated queues: hci_tx_wq (prio 4), gatt_notify_wq (prio 6), and sensor_batch_wq (prio 8). Each queue gets its own thread stack and priority. This prevents a slow sensor batch from delaying a critical HCI packet.
Checklist for Your Next Build
- Profile with SystemView: filter on BLE connection event markers.
- Pin BLE host and HCI threads to the faster core.
- Add priority ceilings to every mutex shared with interrupt context.
- Split work queues by latency class.
- Validate with 24-hour soak test at minimum connection interval (7.5 ms).
✦
Sub-5ms connection events aren’t magic. They’re the result of treating scheduling as a first-class design constraint. Apply these three levers—affinity, ceilings, isolated queues—and your next wearable firmware will breathe like Zephyrus: gentle, westerly, and right on time.









