嵌入式系统中的malloc [英] malloc in embedded systems

查看:33
本文介绍了嵌入式系统中的malloc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I am working with an embedded system. The application is running on AT91SAMxxxx and cortex m3 lpc17xxx. I am looking into dynamic memory allocation as it would dramatically change the face of the application (and give me more Power).

I think the my only real route is to set out an area of memory for a heap and design a tailored malloc that best fits (pun) my purpose.

When looking at different algorithms for memory allocation you cant not stumble upon Doug Lea's malloc. I take it this has been used in embedded systems such as mine where there is no OS and tailored versions of say the sbrk() function have been provided to accomplish this. I'm trying to find good examples of this being achieved to maybe try a proof of concept before I jump into writing my own.

Is it possible to use dlmalloc in a system such as mine ?

If yes can anyone point me to a relevant resource ? (not found many that help me)

Is it better to go and write my own malloc that is tailored to my needs ?

And apologies most of my research so far has been on designing a malloc not using doug's which is a different challenge. Guess I'm trying to find out is looking into this route in more depth a waste of time.

Edit:

moral of the story: looking at dlmalloc in my case pointless.

解决方案

For your situation your own implementation of malloc or dlmalloc is definately possible, but not advisable.

On very low level embedded systems, bare metal MCU's etc, using malloc is pointless.

You will be running your app and only your app on them, you know how much memory you have and can use, and you are fully able to tailor your program to fit such needs. With malloc you save memory, but that is pointless here. If your program at its highest memory usage does not exceed the memory available on the device, and your program is the only one running, there is no reason to use malloc, and no reason to let any memory go unused.

tl;dr Its possible but exceedingly pointless.

这篇关于嵌入式系统中的malloc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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