Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

significance of stack size in an embedded system

Status
Not open for further replies.

bagyavinoth

Junior Member level 1
Junior Member level 1
Joined
Dec 18, 2009
Messages
16
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,410
Hello all,
I just want to acquire in-depth understanding of stack and heap requirements in context to embedded systems. Usually when we start to work on embedded system as a hobbyist, we usually don't care about the stack and heap configurations for our projects. But when we want to make us professionally fit, i think these are required. So i would like people to share their views with respect to this topic. For example let me take P89V51RD2. It has 64kb of rom and 1024 bytes of ram. If i want to use this for my project, what and all i should consider. Please share your views. Thanks.



Regards,
Vinoth
 

Hi,
I take example of keil....

It is the way the Keil ARM-MDK default start-up files for M3 work. It is slightly unusual; more commonly you would specify a stack size, and any remaining memory after stack and static memory allocation by the linker becomes the heap; this is arguably better since you do not end up with a pool of unusable memory. You could modify that and use an alternative scheme, but you'd need to know what you are doing.

If you are using Keil ARM-MDK, the linker options --info=stack and --callgraph add information to the map file that aids stack requirement analysis. These and other techniques are described here.

If you are using an RTOS or multi-tasking kernel, each task will have its own stack. The OS may provide stack analysis tools, Keil's RTX kernel viewer shows current stack usage but not peak stack usage (so is mostly useless, and it only works correctly for tasks with default stack lengths).

If you have to implement stack checking tools yourself, the normal method is to fill the stack with a known value, and starting from the high address, inspect the value until you find the first value that is not the fill byte, this will give the likley high tide mark of the stack. You can implement code to do this, or you can manually fill the memory from the debugger, and then monitor stack usage in a debugger memory window.

Heap requirement will depend on the run-time behaviour of your code; you'll have to analyse that yourself however in ARM/Keil Realview, the MemManage Exception handler will be called when C++'s new throws an exception; I am not sure if malloc() does that or simply returns NULL. You can place a breakpoint in the exception handler or modify the handler to emit an error message to detect heap exhaustion during testing. There is also a a __heapstats() function that can be used to output heap information.

http://www.cis.upenn.edu/~lee/06cse480/lec-emsoft-analysis-p3.pdf
ARM Information Center
http://planete.inrialpes.fr/~perito/papers/vmsec_ccs09.pdf
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top