Automatic Stack Allocation In Flexprop And Catalina?
Hi ersmith and RossH,
Considering how critical Stack allocation is to proper operation when starting new cogs, it should be at the top of the list for the coders as we write programs to take advantage of the multi-cog capability. It should also be at the top of the fault list to examine if the code fails to execute or crashes.
However, determining the actual Stack allocation size required for a cog is difficult because just totaling the amount of bytes used by the auto variables within the function(s) executed by a particular cog and then using that value as the Stack size doesn't work. There's obviously more going on with the compilers and how they assign Stack space.
How does your compiler allocate the Stack space for the initial cog upon power-up since it's not necessary for the user to do that -- the cog just starts up and executes code.
Could a similar technique be used to automatically create the required Stack space when other cogs are activated?
Given the critical nature of Stack allocation, in a perfect world the compilers would allocate the Stack size automatically when new cogs are started and then reclaim that Stack size should the cog ever be stopped.
Not having to worry about Stack allocation would be a big hurdle the coders would have unknowingly cleared right at the outset of the coding process.
Could you provide your thoughts on this and the best way to calculate required Stack allocation if the compilers can't be configured to do that automatically?