Shop OBEX P1 Docs P2 Docs Learn Events
In C, how do you calculate stack_size for cogstart ? — Parallax Forums

In C, how do you calculate stack_size for cogstart ?

twm47099twm47099 Posts: 867
edited 2014-01-03 13:09 in Learn with BlocklyProp
In the Propeller C - Functions Tutorial Multicore Example, the General Multicore Setup has the following statements regarding stack size:

"Declare a stack array with 40 longs (required) + extra for local variables and calculations. Be liberal with the extra memory, and use testing to pare it down after your prototyping is done.
Example: unsigned int stack[40 + 25]; "

Are there general rules to calculating stack size (based on things like number and type of parameters, variables, if-statements, etc.)? Is there C-code to evaluate a cog's stack needs once the program is running (like there are for Spin programs)? Or is the method of testing simply trial and error (start big and keep cutting until something bad happens)?

Thanks,
Tom
Sign In or Register to comment.