Equip your Genius
Welcome to the Parallax Discussion Forums, sign-up to participate.
Learn with BlocklyProp
Stack size for main using C code:
2019-04-09 - 13:12:04
Q1. What is the stack size for main?
Q2. How can a program change the stack size for main?
Q3. Is there a utility app for determining stack usage for all active cogs?
2019-04-09 - 14:28:38
1. The primary stack starts at the end of memory and grows downward toward the end of the program. If you use malloc or calloc it will allocate memory located directly above the end of the program, which reduces the amount of memory available to the primary stack.
2. The primary stack size cannot be increased. It can be decreased by using malloc or calloc.
3. Stack usage can be checked by first prefilling the stack with a known value, and then later check for the value starting from the lowest address. This is fairly straightforward to do for the additional cogs. For the initial cog you must account for malloc'ed space, and take care not to overwrite current stack data when prefilling.
2019-04-09 - 17:35:04
Dave Hein, thanks.