嵌入式应用程序中的内存管理资源 [英] Resources for memory management in embedded application

查看:131
本文介绍了嵌入式应用程序中的内存管理资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在Google中找到了一些文章,但无法确定一个非常实用的实用指南。 p>

DO-178b 禁止动态内存分配,但是如何管理内存呢?提前分配所有内容,并发送指向需要分配的每个功能的指针?在堆栈上分配?使用全局静态分配器(但是它非常类似于动态分配)?



答案可以是常规答案,参考资源或参考资料开源嵌入式系统例如。



澄清:这里的问题不在于内存管理是否可用于嵌入式系统。但是嵌入式系统的优秀设计是什么,以最大限度地提高可靠性。



我不明白为什么静态预分配缓冲池,并动态获取和删除它不同于动态分配内存。

解决方案

作为处理嵌入式系统的人,尽管没有这么严格阅读DO-178B,虽然):




  • 如果你看看u-boot引导加载程序,很多都是用全局放置的结构完成的。根据您的确切应用程序,您可能可以摆脱全局结构和堆栈。当然,这里有重新入侵和相关的问题,并不适用于引导程序,但可能适用于您。

  • 预分配,预分配,预分配。如果您可以在设计时绑定数组/列表结构/ etc的大小,请将其声明为全局(或静态全局 - 查看Ma,封装)。

  • 堆栈是非常有用,在需要的地方使用它,但要小心,因为它可以很容易地保持分配,直到没有堆栈空间。我曾经发现自己调试的一些代码会在多个函数中分配1k个缓冲区用于字符串管理...偶尔,缓冲区的使用将会击中另一个程序的堆栈空间,因为默认堆栈大小为4k。

  • 缓冲池的情况可能取决于它的实现方式。如果您知道您需要传递编译时已知大小的固定大小的缓冲区,处理缓冲池可能比完整的动态分配器更容易证明正确性。您只需要验证缓冲区不能丢失,验证您的处理将不会失败。这里似乎有一些很好的提示: http://www.cotsjournalonline.com/articles/view / 101217


尽管如此,我认为您的答案可能在加入 http://www.do178site.com/


How should I manage memory in my mission critical embedded application?

I found some articles with google, but couldn't pinpoint a really useful practical guide.

The DO-178b forbids dynamic memory allocations, but how will you manage the memory then? Preallocate everything in advance and send a pointer to each function that needs allocation? Allocate it on the stack? Use a global static allocator (but then it's very similar to dynamic allocation)?

Answers can be of the form of regular answer, reference to a resource, or reference to good opensource embedded system for example.

clarification: The issue here is not whether or not memory management is availible for the embedded system. But what is a good design for an embedded system, to maximize reliability.

I don't understand why statically preallocating a buffer pool, and dynamically getting and dropping it, is different from dynamically allocating memory.

解决方案

As someone who has dealt with embedded systems, though not to such rigor so far (I have read DO-178B, though):

  • If you look at the u-boot bootloader, a lot is done with a globally placed structure. Depending on your exact application, you may be able to get away with a global structure and stack. Of course, there are re-entrancy and related issues there that don't really apply to a bootloader but might for you.
  • Preallocate, preallocate, preallocate. If you can at design-time bind the size of an array/list structure/etc, declare it as a global (or static global -- look Ma, encapsulation).
  • The stack is very useful, use it where needed -- but be careful, as it can be easy to keep allocating off of it until you have no stack space left. Some code I once found myself debugging would allocate 1k buffers for string management in multiple functions...occasionally, the usage of the buffers would hit another program's stack space, as the default stack size was 4k.
  • The buffer pool case may depend on exactly how it's implemented. If you know you need to pass around fixed-size buffers of a size known at compile time, dealing with a buffer pool is likely more easy to demonstrate correctness than a complete dynamic allocator. You just need to verify buffers cannot be lost, and validate your handling won't fail. There seem to be some good tips here: http://www.cotsjournalonline.com/articles/view/101217

Really, though, I think your answers might be found in joining http://www.do178site.com/

这篇关于嵌入式应用程序中的内存管理资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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