Easiest Method to find stack size for cogs.
FORD
Posts: 221
Howdy All,
While I try to get my head around stack sizing correctly for a few cogs in a program...
I was wondering if a rough initial method would be to use the parallax spin editor, and after compiling, just click on the PUB line at the top of the method...
...Then the number of bytes in the method show at the bottom of the screen.
Is it ok to just divide the bytes by 4, add another say 20 longs, and use this as a stack size ?
Sorry in advance if my question is completely off track, I'm not far off understanding the stack stuff, but have a little way to go.
Edit : I tried to use the stack finding method to do it, but failed miserably
regards to All,
Chris.
While I try to get my head around stack sizing correctly for a few cogs in a program...
I was wondering if a rough initial method would be to use the parallax spin editor, and after compiling, just click on the PUB line at the top of the method...
...Then the number of bytes in the method show at the bottom of the screen.
Is it ok to just divide the bytes by 4, add another say 20 longs, and use this as a stack size ?
Sorry in advance if my question is completely off track, I'm not far off understanding the stack stuff, but have a little way to go.
Edit : I tried to use the stack finding method to do it, but failed miserably
regards to All,
Chris.
Comments
I've actually just printed that out an hour or so ago, and will have a read in the morning (head spinning and tired now)...
Is my question about the byte data in the editor close to the mark or should I steer clear of it ?
Cheers,
'Chris
I usually experiment. Rough estimate or pick a high number for stack allocation. Then do a brute force halving until I find the threshold.
yes I have done that (extra space allocated), and have plenty of spare memory.
Would be keen to hear from somebody at Parallax to comment on the pro's / cons of using the bytes per PUB reported in the editor.
The easiest approach is to use Mike G's approach where you use large stacks at first. There's at least one method in the OBEX that will pre-fill the stacks with a known pattern, and then you can measure how much of the stack was unused after running your program.
Your reply has cleared that up for me, and thanks for the tip for the obex object, I'll start searching for it now.