Forum Index
Task Stack Warning in Native mode

 
Author Message
spamiam



Joined: 13 Nov 2005

Posted: 06 October 2008, 3:26 AM    Post subject: Task Stack Warning in Native mode

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
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Location: Portland, OR

Posted: 06 October 2008, 3:40 AM    Post subject: Re: Task Stack Warning in Native mode

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.
Back to top
spamiam



Joined: 13 Nov 2005

Posted: 06 October 2008, 12:16 PM    Post subject: Re: Task Stack Warning in Native mode

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
Back to top
spamiam



Joined: 13 Nov 2005

Posted: 07 October 2008, 3:15 AM    Post subject:

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
Back to top
Display posts from previous:   
Page 1 of 1

 



ZBasic Microcontrollers Home
All content Copyright © 2005, 2006, 2007, 2008 Elba Corp. All Rights Reserved.
Opinions expressed in posts are those of the author and not necessarily those of Elba Corp.
Powered by phpBB © 2001, 2005 phpBB Group