Stack usage in a task

willywortel wrote on Sunday, November 09, 2008:

What is the best way to determine how many stack I need to assign to a task?

edwards3 wrote on Sunday, November 09, 2008:

Well you could try calculating it [max function call depth + plus max interrupt nesting depth + etc] but really trial and error is the best way. Start at [configMINIMAL_STACK_SIZE * 2], let the task run for a bit, then inspect the high water mark using http://www.freertos.org/uxTaskGetStackHighWaterMark.html and adjust as fit.

If the task does not get that far use http://www.freertos.org/Stacks-and-stack-overflow-checking.html to trap errors.

The new MPLAB and Eclipse plugins make this easier as they display the high water mark.

willywortel wrote on Sunday, November 09, 2008:

Ah, didn’t know that kind of (powerfull) tools.

How about the plugin? I have the latest version (not beta) of MPlab.

willywortel wrote on Sunday, November 09, 2008:

*just curious, how big is the minimal_stack_size ? I mean, how many stacks can it contain?

edwards3 wrote on Sunday, November 09, 2008:

It is sized so the idle task can run without crashing, but how big that has to be depends on the architecture. The idle task does not do anything so only requires a small stack.