2 years, 11 months ago.

Isn't fixed stack size only true for RTOS?

In the first paragraph you write:


Not only is memory limited, but also microcontrollers do not have an MMU and therefore cannot move memory blocks around without changing addresses. This lack of virtual memory means you have to have fixed stack sizes, so you can run into a stack overflow error even when there is still RAM available.

If I understand the memory model correctly, this is only true for mbed OS, and probably in general for an RTOS. However if you just use plain mbed, you do have a variable stack size: It simply grows towards the heap.

Question relating to:

1 Answer

2 years, 11 months ago.

In case of mbed classic (without RTOS) you have only one thread, so you can think about all the free memory as your stack. But as soon as you introduce RTOS and threads (the main function runs as a thread) you need to partition the memory to allow for spawning multiple threads.