Posted by Nobody/Anonymous on February 8, 2006
Can you point me at some more information about the configMINIMAL_STACK_SIZE parameter? I am using the Philips LPC2103 with 8K of internal SRAM and for obvious reasons would like to minimize the amount used by the OS.
Posted by Richard
on February 8, 2006
As with any program or function the amount of stack necessary is dependent on the number of local (stack)variables, the function call nesting depth, how library functions are used (like printf which is very stack hungry) and how interrupts use the stack. You can write your software to minimise stack usage if this is your priority.
The only place configMINIMAL_STACK_SIZE is actually used within the scheduler source code itself is to size the stack used by the idle task. However, in the demo projects it is also used to size the stack for the majority of the demo application tasks (in the demo/common directory). A consequence of this is that the demo application projects tend to set configMINIMAL_STACK_SIZE to a value greater than the scheduler itself actually needs.
You can define your application stack sizes to be whatever you want and tailor the size to each task. This would allow you to set the minimal stack definition to be smaller as it would only then be used by the idle task.
You can use the usTaskCheckFreeStackSpace() function (not in release code!) to see if you have enough wiggle room for your settings. Alternatively you can simple run the code in a debugger and check the stacks high water mask.
Remember that the stack has to be large enough for the context to be saved onto the stack by the scheduler.
FreeRTOS 4 should be available by the beginning of April. This has a new feature for stack limited systems.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.