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

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

问题描述

如何我应该在关键任务嵌入式应用管理内存?

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.

DO-178B 禁止动态内存分配,但你将如何管理内存呢? preallocate一切都事先并发送一个指向需要分配每个功能?它分配在堆栈上?使用一个全局静态分配器(但它非常类似于动态分配)?

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.

我不明白为什么静态preallocating一个缓冲池,并动态地获取和放弃它,是动态分配的内存不同。

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

推荐答案

正如有人谁处理了嵌入式系统,虽然没有这样的严格至今(我读DO-178B,虽然):

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


  • 如果你看一下U-Boot的引导程序,很多是用全球放置结构完成的。根据您的具体的应用程序,你可以逃脱一个全球性的结构和堆栈。当然,也有重入并有相关的问题并不真正适用于引导程序,但可能适合你。

  • preallocate,preallocate,preallocate。如果你能在设计时绑定的数组/链表结构的/ etc的大小,声明它作为一个全球性(或静态全局 - 看马,封装)。

  • 堆栈是非常有用的,它用在需要的地方 - 但要小心,因为它可以很容易保持分配关闭它,直到你有没有留下堆栈空间。有些code有一次,我发现自己的调试将分配字符串管理1K缓冲区的多种功能......偶尔,缓冲区的使用将再创程序的堆栈空间,默认的堆栈大小为4K。

  • 缓冲池的情况下可能取决于这正是如何实现的。如果你知道你需要通过在编译时已知大小的周围固定大小的缓冲区,处理一个缓冲池可能更容易证明不是一个完整的动态分配的正确性。你只需要验证缓冲区不能丢失,和验证操作不会失败。似乎有这里一些好的建议: http://www.cotsjournalonline.com/articles/view/ 101217

  • 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

真的,不过,我认为你的答案可能加盟 http://www.do178site.com/

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

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

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