Description
Description
- Type: Enhancement
Enhancement
Reason to enhance or problem with existing solution
Mbed RTOS has a significant RAM overhead, even when non of the RTOS features are used. A K64F running mbed-os-example-blinky uses 6.3K more static RAM, even though it does not use any of the RTOS features. I suspect this memory goes into setting up all the RTOS contexts. What I'd like to see is some configuration option - not enabled by default - which still keeps the RTOS and features such as Semaphores, but without the RAM overhead. We could call it single thread mode. In addition, we could offer to enable newlib-nano / the ARMCC equivalent for these devices, shrinking memory usage even further.
This would make it easier to run Mbed OS on smaller targets like the DISCO-LRWAN1 which has 20K SRAM, and uses 19K of this when you have the LoRaWAN stack loaded; or even the xDot which has 32K SRAM. Often you want to squeeze as much out of these MCUs as possible, and switching to a single thread model is not such a bad idea if that means you can save 10K of RAM.
Here are some numbers (mbed-os-example-blinky on K64F with printf
used, running a develop profile):
Configuration | Static RAM |
---|---|
With RTOS | 12264 |
Without RTOS | 5876 |
Without RTOS + newlib-nano | 3276 |
Suggested enhancement
Introduce a single thread mode. All RTOS functions (except Thread?) should still be available, so this will work with LwIP and the Ethernet interfaces where RTOS functions are used for synchronisation. But memory usage should be similar to running without the RTOS.
Pros
More space on device, without having to rewrite some code because all the RTOS / synchronisation features are lost. F.e. Semaphore is very useful for switching between ISR and main thread, but is no longer available when removing the RTOS right now. Also a good way to show OEMs how to shrink down their application, and gives us a supported path for smaller MCUs.
Cons
Could maybe lead to people writing non-thread safe drivers.