when i'm using _mem_alloc(size)
mqx allocates memory over tasks stacks
I want allocate memory from secify task stack (task with _mem_alloc execute). Is it possible?
How check how many free ram memory left in IAR using MQX TAD plugin?
Declaring the variable within the task will use the task stack.
Using the _mem_alloc() get memory from the heap.
Declaring a variable "static" will place it in the BSS space.
Note that the Kinetis family with 128KB SRAM actually has that memory in two 64KB blocks. The architecture doesn't let you allocate variable across the 0x2000_0000 boundary. So to declare a 64KB or larger memory block needs to be parsed/divided into smaller blocks. I've attached ".gif" to show the heap used for two big buffers. I've also attached the source file I used to play around on the TWRK60.
Hope this helps.
_mem_alloc() should not alloc over your task stacks. One possibility is that the task that is calling _mem_alloc() to allocate the memory for the task stacks might be exiting. The MQX behavior on a task exiting is to free all memory it has allocated. Find out what task is initializing your other tasks and make sure it is not exiting.
my task is very simply:
void Easy_Task(uint_32 dummy)
void * mem = _mem_alloc(32); _mem_free(mem);
In stack usage I see that stack for this task is from 0x...d490 ti 0x...d590 (256 bytes)
and my local variable address is 0x...d5ac so its over stack!
The _mem_alloc() function call is getting space from the system heap and not from the task stack.
But is any chance (method) to get it from task stack?
Im using k60n512 with 128kB ram. I'm using _mem_alloc() to alloc memory but when I try alloc more than 64kB function gives me NULL (so mqx can not allocate) - I dont know why? I think that simple task can not takes other 64kb! Where problem is?
Retrieving data ...