
RTOS Scheduling — What Nobody Told You
Motor controller. Production hardware. The system would run perfectly for hours, then suddenly freeze — no crash, no fault handler, just... silence. The watchdog would reset everything and we'd be back in business. For about six hours. It took me two days to figure out it was a priority inversion. A low-priority logging task was holding a mutex that a high-priority motor task needed. A medium-priority CAN handler kept preempting the logger. The motor task starved. The watchdog fired. I'd been writing RTOS code for a year at that point. I thought I understood scheduling. I did not. This post is everything I learned the hard way — written for you, so you don't have to spend two days staring at a logic analyzer. <10µs Context switch on Cortex-M4 @ 168MHz O(1) Task selection — single CLZ instruction 69.3% Max CPU utilization under RMA (n→∞) First, Let's Kill a Myth The most common thing I see new embedded engineers get wrong: they think an RTOS makes their system faster. It doesn't. It mak
Continue reading on Dev.to Webdev
Opens in a new tab



