Task Stack Warning in Native mode

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Task Stack Warning in Native mode

Post by spamiam »

Under what conditions would I get no warning about an excessively small task stack in Native mode?

I have 2 tasks running. I had the tasks sized for the ZVM mode, and when I compiled under Native mode one of the task stacks got an error indicating that the stack needed to be at least 70 bytes larger (120 vs 50).

I got no warning about the other task stack, but I was getting odd stuff happening and I tracked it down (I think) to the task stack being rather too small. Since I got no warning, I had no good idea about how big to make it, so I added 100 bytes just as a starting point. This seems to be OK because I no longer have any oddities (other than the evaluation of the Select Case statements).

Is there a way for me to determine how big I need the task stack to be in Native mode?

-Tony
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Task Stack Warning in Native mode

Post by dkinzer »

spamiam wrote:Is there a way for me to determine how big I need the task stack to be in Native mode?
Recent versions of the compiler calculate the task stack size for native mode. The results are believed to be accurate; typically producing a required stack size that is larger than the value calculated by subtracting the value returned by System.TaskHeadRoom() from the actual task stack size. Of course, you need to be certain that your task is well-exercised prior to requesting the headroom calculation; otherwise, you may get a misleading result.

It is certainly possible that there is an error in the calculation algorithm that causes the computed value to be less than the observed value. I would very much like to take a look at ZBasic code that produces such a result.
- Don Kinzer
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Re: Task Stack Warning in Native mode

Post by spamiam »

dkinzer wrote:It is certainly possible that there is an error in the calculation algorithm that causes the computed value to be less than the observed value. I would very much like to take a look at ZBasic code that produces such a result.
I suppose that the fact that I did not get a warning on the second task, whose stack was evidently too small (because it was clobbering other variables) indicates that it was calculating too small a stack size.

I will clip the code for the task including the variable allocations and get it to you this evening when I get home.

-Tony
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Post by spamiam »

I tested the stack warning just now after fixing up some other stuff. I set the stack too low again (adequate for ZVM mode) and I got an error. I may have missed it because I get a few other errors about variables being hiding some system functions and some of my global variables.

I think the stack warning is working properly.

-Tony
Post Reply