I built a careful system for moving late tasks from Linux to a real-time microcontroller. It never moved anything, and that turned out to be the right answer.
The Arduino UNO Q is two computers on one board. One is a quad-core Arm Cortex-A53 running Debian Linux: fast, flexible, and shared with everything else on the system. The other is an STM32 microcontroller, a Cortex-M33 running the Zephyr real-time OS: slow and small, but it does one thing at a time and does it on schedule.
That pairing invites an obvious idea. When a task starts missing its deadlines because Linux got busy, move it to the microcontroller. The predictable chip should be a refuge.
I spent a few weeks building that idea properly, measuring it honestly, and writing it up as a paper, QFabric (arXiv:2611.01598). The short version: the refuge doesn't exist on this board, and the interesting part is why.
Moving a task is not free
On a laptop, the OS can move a thread between cores for nothing. On a board like the UNO Q, the two processors run different operating systems. "Moving" a task means running a different binary on a different chip and shipping its input across a link. That raises four problems:
- Transport. Every input must be packed up, sent across, unpacked, and the result sent back.
- Speed. The microcontroller is much slower. On my heaviest test kernel it was 34× slower than the Linux cores.
- Legality. A task that reads a socket or a file can't run on the microcontroller at all.
- Thrashing. Moving back and forth on every hiccup can be worse than never moving.
So I designed QFabric to be cautious. Each task gets a timing contract ("at most 1% of calls may exceed the deadline"), and the controller watches it in windows of 20 calls. Before moving anything it insists on:
- Three bad windows in a row, so one stall doesn't trigger a move.
- A legal, affordable move. The task must be side-effect free, the microcontroller must have spare capacity, and the move must be predicted to meet the deadline.
- A clean cut. Stop new calls, wait until nothing is in flight, bump an epoch counter, then switch.
- Probation. Watch six more windows. Keep the move only if the contract now holds; otherwise roll it back.
A prediction only earns a trial, never a permanent move. That rule ended up mattering more than anything else.
Then I measured it, and my first result was wrong
My first version reported that recovery cut tail latency by 36.6%. It looked great. It was wrong, for two reasons I only found by re-reading my own measurement code.
First, the Linux side was timing the wrong thing. Every Linux call launched a brand-new process. So "Linux latency" was mostly process start-up: 8 ms for adding two numbers. With a long-running process instead, the same addition takes 0.075 ms.
Second, the comparison wasn't fair. I replayed microcontroller timings recorded on an idle system against Linux timings recorded under load. But every microcontroller call starts in Linux, so it should have been slowed by the same load.
So I threw that result away and did it again properly. This time I wrote the deadline rule and the analysis down and committed them to the repository before collecting any new data, so I couldn't tune them to get a nicer answer. Then I measured five workloads (an addition, a CRC-32, and an FIR filter at three sizes) on both sides, under three conditions: idle, normal CPU load, and a higher-priority real-time program hogging the CPUs half the time. That's 12 runs and 120,000 calls on the real board.
What the board actually does
Every microcontroller call costs about 19 ms, whatever it computes. An addition on Linux: 0.075 ms. The same addition on the microcontroller: 18.8 ms. Nearly all of it is getting there and back, not the work itself.
And then the surprise. Under the real-time hog, Linux load hurt the microcontroller path far more than Linux itself. The microcontroller path's worst 1% of calls hit about 400 ms; the Linux path stayed under 17 ms.
Once you trace a single call, it makes sense. To reach the microcontroller, a call goes from my program into a Linux router process over a socket, then down a serial line, then all the way back. That's several Linux processes, each of which can be delayed. A Linux call needs one free core, once. Moving the task to the microcontroller doesn't move its dispatch off Linux. The interference follows it across the board.
The controller did the right thing by doing nothing
Across 30 combinations of workload, load and caller, Linux met every contract, and QFabric made zero moves. Moving would never have helped.
To see whether the caution was worth it, I removed one safeguard: the "three bad windows in a row" rule. The stripped-down controller reacted to isolated Linux stalls and moved tasks in 7 cases. Tail latency got up to 177× worse; one addition went from 0.58 ms to 103 ms at the 95th percentile. Probation caught and rolled back 5 of those 7 bad moves.
So the safeguards weren't paperwork. Without them, a reasonable-looking controller turns sub-millisecond tails into 100-millisecond ones.
What I'd tell anyone building on these boards
- A real-time core only protects work whose dispatch also leaves Linux. If Linux sends every call, Linux problems reach every call. To get real isolation, let the microcontroller run the loop itself on its own timer, use a faster link such as shared memory, or move the dispatcher out of Linux userspace.
- Measure the path, not just the compute. The microcontroller's compute was a tiny part of its cost.
- Treat any automatic migration as a hypothesis. Make it prove itself before you keep it.
- Re-read your own measurement code. My most important finding was a bug in my first result.
Read more
- The paper: arXiv:2611.01598
- Code, raw traces and the scripts that produce every number: github.com/elixpo/qfabric, archived at doi.org/10.5281/zenodo.23692354
Written with Anwesha Chakraborty, my co-author on the paper.
