TI中文支持网
TI专业的中文技术问题搜集分享网站

关于cmd中堆和栈分配

我cmd文件分配如下,请问:

1 stack分配是根据在子函数中用到的最大的局部变量,比如数组大小来分配的么?而heap分配是根据malloc分配内存的和来计算得么?

2stack可以定位到段.stack,但是heap为啥没有在section中定位,或者他默认定位在哪里?(这样我知道heap是分配咋哪个section了)

3比如我分配动态分配内存用的形式是 "ping = (Uint16*)MEM_alloc(DDR2HEAP,sizeof(Uint16)*roLength,32)", 所以第一个参数需要指定heap位置,如果2中没有指定位置,我第一个参数该怎么写?

谢谢大神解答

-stack 0x00001800 /* Stack Size */
-heap 0x00001800 /* Heap Size */

MEMORY
{
L2RAM: o = 0x10800000 l = 0x00020000
DDR2: o = 0x80000000 l = 0x10000000
Flash: o = 0x90000000 l = 0x00400000
}

SECTIONS
{
.bss > L2RAM
.cinit > L2RAM
.cio > L2RAM
.const > L2RAM
.data > L2RAM
.far > L2RAM
.stack > DDR2
.switch > L2RAM
.sysmem > L2RAM
.text > L2RAM
.ddr2 > DDR2
.buffer > DDR2
}

/*
SECTIONS
{
.bss > DDR2
.cinit > DDR2
.cio > DDR2
.const > DDR2
.data > DDR2
.far > DDR2
.stack > DDR2
.switch > DDR2
.sysmem > DDR2
.text > DDR2
}
*/

HG:

memory section managermem_alloc第一个参数指定的是内存分配的位置,其值与系统内存heap的定义相关。

Q: Why users are not allowed to call MEM functions (MEM_alloc, MEM_stat etc) from an HWI or SWI?

Memory management functions ( MEM_alloc(), MEM_stat(), MEM_free()) are blocking calls. This is because the functions require the caller to acquire a lock to the memory before proceeding. In case the MEM functions fail to get a lock to the memory, there is a context switch. A call to a SWI or HWI routine should be non-blocking in nature and hence TI recommends that customer should not call MEM functions inside a SWI or HWI. In case the user makes blocking calls (MEM calls) inside a SWI or HWI, the behavior is not guaranteed. Making any blocking calls from a HWI or SWI can affect the real time response of the system.

赞(0)
未经允许不得转载:TI中文支持网 » 关于cmd中堆和栈分配
分享到: 更多 (0)