On 2011-08-29, JMGross <msp...@grossibaer.de> wrote:

>> I've been reading this thread for a while and it 
>> makes me wonder if there is some kind of tool 
>> which can analyze the code and determine the 
>> stack usage? I think this may be a safer route 
>> than to depend on a real-time stack check. The 
>> big question is: what do you do when the stack 
>> overflows? Just resetting the MCU is probably not 
>> an option so you'll have to add extra code to 
>> handle such an 'exception'. That does not seem very trivial to me.
>
> Stack usage is a dynamic thing and happens at real-time. 
> Unless you code a benchmarck that always executes 
> exactly the same way, there is no way to determine stack 
> usage.

That's not always true.  I theory, if your call tree is static (no
calls via pointers or other "computed" means), then you can determine
the stack usage by static examination of the call tree since the frame
size for each function is know.  Then you have to add on top of that
the stack usage by the interrupts (if you don't nest interrupts,
that's pretty straight-forward)

> Some minor, small projects might be analyzeable, but for the
> majority, it's up to you to guess and hope :)

If you're lucky, you can do your prototyping and testing with a chip
that has extra RAM.  That way you can allocate plenty of stack space
to each thread, fill the stack with an identifiable pattern, and then 
measure the stack usage after have done stress-testing testing that
covers as much of the call tree as possible.  Then you multiply your
measured stack usage by a fudge-factor and cross your fingers.

-- 
Grant


------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to