Resources for memory management in embedded application

前端 未结 7 771
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-31 17:50

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.

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-31 18:12

    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/

提交回复
热议问题