[En-Nut-Discussion] stack size

duane ellis ethernut at duaneellis.com
Thu Mar 27 01:49:36 CET 2008


Ernst Stippl>>  (a..d) [list of things that eat stack space]

You forgot:

w) that IRQs may nest (not supported yet by Nut)
x) and C routines the IRQs may call (ie: strcpy, memcpy, mul/divide, etc)
y) dynamic space allocated by alloca()
z) And structures that are passed/returned by value, not pointer.

Alain M. wrote:
> When I allocate a stack I clear it all to 0x00. 

I prefer:  0xDeadBeef, or 0xDefaCa8d  :-)

Often filling is the simple solution.

the ascii text "STAKSTAK" - very readable with ascii memory dumps.

BTW - GCC has a -fstack-check option and many others, like: 
'-fstack-limit-symbol='

Your results may vary, there are also target specific options, some 
targets have specific support.

When thread switch, something needs to be done that is thread specific. 
Not always trivial.

The old Microsoft compiler had a call to __chkstk() function - forced at 
the start of every function.
You could create your own.. Not sure if GCC has something like that, it 
would be very nice if it did.

Experimentation and hocus - pocus is perhaps the easiest approach.

The exact approach is $$$EXPENSIVE$$$ in time spent calculating that 
number.

-Duane.





More information about the En-Nut-Discussion mailing list