Difference between revisions of "Stack Analysis"
JohnRegehr (talk | contribs) (New page: Image:Memmap.png = What is Stack Depth Analysis? = Most of the time, a function call results in allocation of stack memory. The RAM = Who Needs to Care About Stack Overflow? =) |
JohnRegehr (talk | contribs) (→What is Stack Depth Analysis?) |
||
Line 3: | Line 3: | ||
= What is Stack Depth Analysis? = | = What is Stack Depth Analysis? = | ||
− | + | Calling a function or handling an interrupt requires allocation of memory from the ''stack memory region''. If the stack memory region is not large enough to hold the stack, RAM is corrupted, leading to difficult, non-deterministic node failure. For obvious reasons these failures cannot be replicated in TOSSIM. | |
+ | |||
+ | In a TinyOS application (as in any embedded system lacking virtual memory) the size of the stack is determined statically and it is important that the size be chosen appropriately. The stack region must not be too small. If it is too large the system will operate correctly, but RAM that could have been put to good use is wasted. | ||
+ | |||
+ | TinyOS (without TOSThreads) has a single stack. When a heap is not in use, the size of the stack memory region is simply: | ||
+ | |||
+ | <math>\mbox{RAM size} - \mbox{data segment size} - \mbox{BSS segment size}</math> | ||
= Who Needs to Care About Stack Overflow? = | = Who Needs to Care About Stack Overflow? = |
Revision as of 12:46, 13 April 2009
What is Stack Depth Analysis?
Calling a function or handling an interrupt requires allocation of memory from the stack memory region. If the stack memory region is not large enough to hold the stack, RAM is corrupted, leading to difficult, non-deterministic node failure. For obvious reasons these failures cannot be replicated in TOSSIM.
In a TinyOS application (as in any embedded system lacking virtual memory) the size of the stack is determined statically and it is important that the size be chosen appropriately. The stack region must not be too small. If it is too large the system will operate correctly, but RAM that could have been put to good use is wasted.
TinyOS (without TOSThreads) has a single stack. When a heap is not in use, the size of the stack memory region is simply:
<math>\mbox{RAM size} - \mbox{data segment size} - \mbox{BSS segment size}</math>