如何确定最大堆栈使用率? [英] How to determine maximum stack usage?

查看:348
本文介绍了如何确定最大堆栈使用率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

确定嵌入式/内存限制系统的最佳堆栈大小有哪些方法可用?如果它太大,那么内存被浪费,可以在其他地方使用。然而,如果它太小,那么我们得到这个网站的名字...



要尝试跳开始的事情:Jack Ganssle在 设计嵌入式系统的艺术 有经验的人学习标准,科学的方法来计算一个堆栈的适当大小:选择一个大小随机和希望。任何人都可以做得更好吗?



一个更具体的例子被要求那么,针对的C程式如何呢? MSP430 MCU 与2 kB的RAM使用 IAR Embedded Workbench 没有操作系统的工具链?该IDE可以在使用JTAG调试器时显示堆栈内容和使用情况。

解决方案

确定最深堆栈使用的最常见方式是使用一些已知但不寻常的值初始化堆栈内存,然后定期(或在大测试运行结束时)查看该模式停止的位置。



IAR IDE如何确定使用的堆栈数量。


What methods are available for determining the optimum stack size for embedded/memory constrained system? If it's too big then memory is wasted that could be used elsewhere. However, if it is too small then we get this website's namesake...

To try to jump start things: Jack Ganssle states in The Art of Designing Embedded Systems that, "With experience, one learns the standard, scientific way to compute the proper size for a stack: Pick a size at random and hope." Can anyone do better than that?

A more specific example was requested. So, how about a C program targeting an MSP430 MCU with 2 kB of RAM using the IAR Embedded Workbench toolchain without an operating system? This IDE can display the stack contents and usage while using a JTAG debugger.

解决方案

The most common way to determine the deepest stack usage is to initialize the stack memory with some known but unusual value, then periodically (or at the end of a big test run) see where that pattern stops.

This is exactly how the IAR IDE determines the amount of stack used.

这篇关于如何确定最大堆栈使用率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆