AnsweredAssumed Answered

Allocation in system memory

Question asked by Alessandra Orlandini on Mar 31, 2016
Latest reply on Apr 13, 2016 by Carlos_Musich

Hi to all,

I have two questions about memory management with MQX.

The first question is basic and due to my short experience on this OS:

I know that both _mem_ alloc and _mem_alloc_system allocate data into default pool,  to a private task or to a generic system task, respectively.

In general, the memory private ownership of a task could be a limit generating wrong deallocation and memory consumption.

--> According to your experience, could I always exploit system memory allocation safely and without secondary effects?


On the other hand,  to overcome the private ownership,  I made an exercise using _mem_transfer

instruction before memory deallocation, as follows:


  _task_number taskn = GET_MEMBLOCK_PTR(memory)->TASK_NUMBER;

  if ((taskn != TASK_NUMBER_FROM_TASKID(task_get_id()) && (taskn != TASK_NUMBER_FROM_TASKID(_mqx_get_system_task_id()))

  _mem_transfer(memory, BUILD_TASKID(kernel_data->INIT.PROCESSOR_NUMBER, task_num), _mqx_get_system_task_id);


Above I supposed to know a priori the processor number of the task owner.

My question is:

Is there a way to infer the task id (processor number + task number) of the owner task directly from  memory block structure?