In C, how do you calculate stack_size for cogstart ?
twm47099
Posts: 867
Sorry for the cross post - I posted this originally in the Learn forum and got no response. Maybe in the c forum?? I added a little more info here. I guess a related question that might help me figure out how to size it is what is the stack used for in the new cog?
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]; "
I've just used stack[50 + 50]; so far and it has worked for my application, but --
Are there general rules to calculating stack size (based on things like number and type of parameters, variables, function calls, 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
I appreciate the information. Thanks again.
Tom
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]; "
I've just used stack[50 + 50]; so far and it has worked for my application, but --
Are there general rules to calculating stack size (based on things like number and type of parameters, variables, function calls, 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
I appreciate the information. Thanks again.
Tom
Comments