10 years, 9 months ago.

Stack size of tasks

Using the FRDM-KLZ25 board from Freescale.

I have noticed the stack size of a task defined in cmsis_os.h DEFAULT_STACK_SIZE is about 2kbytes. For a simple task this is a bit of an overkill.

Is there a way to determine the max stack needed for a task? I have used 128 bytes with no problem.

Task was flashing and LED with delay.

Thank you.

Question relating to:

3 Answers

10 years, 9 months ago.

I had a while ago the same question, see: http://mbed.org/questions/1280/Ram-usage-of-Threads/

Georg Lerm
poster
10 years, 9 months ago.

Thank you Erik. Seems that with 2K stack per thread on a KL25Z 4 threads is about the limit. Main thread and 3 other...

6 years, 1 month ago.

Note that in Mbed OS 5 you can set stack sizes through the Mbed OS configuration system. See the documentation for more information.