[En-Nut-Discussion] stack size

Ernst Stippl ernst at stippl.org
Wed Mar 26 22:48:43 CET 2008


Hi Nathan!

I have already thought about how to find out and document stack space
requirements for API functions, but I have not found a solution.

The stack space used is the sum of
a) - local variables
b) - stack space needed by the compiler in case of complex statements (in
case intermediate registers need to get saved (I assume!)
c) - stack space needed by functions called by the API functions (and now
the whole thing starts over...)
d) - stack space needed by interrupt routines
e) - stack space used by clib (or other) library functions

This is dynamic, i.e. it can't be predicted. (at least I don’t know how)

I guess what would be needed are 

- either a compiler which analyzes the possible flows thru the various API
functions to build up the layout of a "dummy stack". This would cover a) and
c)

- or a little hack to use NutHeapAllocClear instead of NutHeapAlloc when
allocating the stack of a new thread and then have a number of controlled
API function calls with an "how much did the "cleared" content of the stack
change during the function call.

- or finding an avr simulator which has functions (or hooks) to be able to
analyze how the stackpointer changes during a certain flow thru the program


I just goggled for " stack analysis by compiler avr " and it came up with
quite a number of references which look interesting, but do not provide any
ad hoc answer. 


What I normally do is trial-and-error. Starting at (size of local vars) plus
512 bytes, increasing by 256. If I know there will be quite a number of
function calls within my own code, I take 1024. 

How do you tackle that question?
 
Regards
Ernst


-----Ursprüngliche Nachricht-----
Von: en-nut-discussion-bounces at egnite.de
[mailto:en-nut-discussion-bounces at egnite.de] Im Auftrag von Nathan Moore
Gesendet: Montag, 17. März 2008 17:52
An: Ethernut User Chat (English)
Betreff: [En-Nut-Discussion] stack size

Are there any recommendations for the minimum stack size for a thread and/or
any info on the stack space used by various API functions?


Nathan
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion



-- 
No virus found in this incoming message.
Checked by AVG. 
Version: 7.5.519 / Virus Database: 269.21.7/1332 - Release Date: 17.03.2008
10:48





More information about the En-Nut-Discussion mailing list