http://www.zbasic.net/download/ZBasic/2 ... _2-5-6.zip
We would like to have the new feature tested on as much "real world" code as possible. In particular, we are interested in data comparing the values produced by the estimation algorithm to the values determined by System.TaskHeadRoom(). There has been one reported case where the estimated value is less than that reported by the headroom analysis but we haven't yet been able to analyze the ZBasic source code to determine what circumstances lead to that result. In most cases, the estimated value should be higher than the measured value because the estimate is based on "worst case" combinations that may not occur during the test execution period.
The native task stack size estimation uses a technique similar to that used for VM mode. The compiler determines the minimum stack size for a task by summing these values:
- the maximum stack depth of the task together with all the routines it calls
- the maximum of:
- the stack use of each ISR considered separately
- the task switch context size (37 or 38 bytes, the latter for devices with > 64K of Flash)
- the size of the Task Control Block (13 bytes)
- the stack margin (default: 10 bytes)
The highest stack use of the ISRs provided by the ZBasic Library is around 22 bytes so unless you define your own ISR, the stack depth used for the task switch context will always be larger than the largest ISR stack use.
The updated compiler now outputs information to the .map file for native mode compilations. Although the amount of data in the .map file is less than for VM mode, the most important data found there is the list of known tasks and the minimum stack size for each. There may be cases where the task stack size cannot be determined. In such a case, the task stack size is listed as ???. We are especially interested in the cases where this occurs.
You can suppress the task size analysis (for either VM or native mode) using the new compiler option --no-analyze-stack-use.
For special circumstances, a new pragma was introduced that allows you to tell the compiler how much stack space a routine or ISR uses. When used within a routine or an ISR, the syntax is:
Code: Select all
#pragma StackUse(<stack-depth>)
Code: Select all
#pragma Stackuse(<routine-name>, <stack-depth>)
Lastly, the Option StackMargin directive has been modified to allow a negative value to be specified. This might be useful if you are convinced that the compiler over estimates the minimum stack size and you'd like to tune it downward.