<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Allocation in system memory in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/Allocation-in-system-memory/m-p/465542#M15532</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Alessandra,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;_mem_alloc()&lt;/STRONG&gt; calls &lt;STRONG&gt; _GET_KERNEL_DATA(kernel_data);&lt;/STRONG&gt; followed by next code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;result = _lwmem_alloc_internal(requested_size, kernel_data-&amp;gt;ACTIVE_PTR,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (_lwmem_pool_id) kernel_data-&amp;gt;KERNEL_LWMEM_POOL, FALSE);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here you will find &lt;STRONG&gt;LWMEM_BLOCK_STRUCT_PTR block_ptr; &lt;/STRONG&gt;which contains the owner task number. However, this information is internal, you may need either to reproduce all the private structures in your application or modify BSP to save the task number that called the mem_alloc() and make it readable for your application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Carlos&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 13 Apr 2016 00:27:46 GMT</pubDate>
    <dc:creator>Carlos_Musich</dc:creator>
    <dc:date>2016-04-13T00:27:46Z</dc:date>
    <item>
      <title>Allocation in system memory</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Allocation-in-system-memory/m-p/465541#M15531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi to all, &lt;/P&gt;&lt;P&gt;I have two questions about memory management with MQX.&lt;/P&gt;&lt;P&gt;The first question is basic and due to my short experience on this OS:&lt;/P&gt;&lt;P&gt;I know that both&lt;EM&gt; _mem_ alloc&lt;/EM&gt; and &lt;EM&gt;_mem_alloc_system&lt;/EM&gt; allocate data into &lt;EM&gt;default pool&lt;/EM&gt;,&amp;nbsp; to a private task or to a generic system task, respectively.&lt;/P&gt;&lt;P&gt;In general, the memory private ownership of a task could be a limit generating wrong deallocation and memory consumption. &lt;/P&gt;&lt;P&gt;--&amp;gt; According to your experience, could I always exploit system memory allocation safely and without secondary effects?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the other hand,&amp;nbsp; to overcome the private ownership,&amp;nbsp; I made an exercise using &lt;EM&gt;_mem_transfer &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;instruction before memory deallocation, as follows:&lt;/P&gt;&lt;P&gt;#ifdef TEST_MEM_TRANSFER&lt;/P&gt;&lt;P&gt;&amp;nbsp; _task_number taskn = GET_MEMBLOCK_PTR(memory)-&amp;gt;TASK_NUMBER;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if ((taskn != TASK_NUMBER_FROM_TASKID(task_get_id()) &amp;amp;&amp;amp; (taskn != TASK_NUMBER_FROM_TASKID(_mqx_get_system_task_id()))&lt;/P&gt;&lt;P&gt;&amp;nbsp; _mem_transfer(memory, BUILD_TASKID(kernel_data-&amp;gt;INIT.PROCESSOR_NUMBER, task_num), _mqx_get_system_task_id);&lt;/P&gt;&lt;P&gt;#endif&lt;/P&gt;&lt;P&gt;Above I supposed to know a priori the processor number of the task owner.&lt;/P&gt;&lt;P&gt;My question is:&lt;/P&gt;&lt;P&gt;Is there a way to infer the task id (processor number + task number) of the owner task directly from&amp;nbsp; memory block structure?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Mar 2016 09:28:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Allocation-in-system-memory/m-p/465541#M15531</guid>
      <dc:creator>alessandraorlan</dc:creator>
      <dc:date>2016-03-31T09:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: Allocation in system memory</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Allocation-in-system-memory/m-p/465542#M15532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Alessandra,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;_mem_alloc()&lt;/STRONG&gt; calls &lt;STRONG&gt; _GET_KERNEL_DATA(kernel_data);&lt;/STRONG&gt; followed by next code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;result = _lwmem_alloc_internal(requested_size, kernel_data-&amp;gt;ACTIVE_PTR,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (_lwmem_pool_id) kernel_data-&amp;gt;KERNEL_LWMEM_POOL, FALSE);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here you will find &lt;STRONG&gt;LWMEM_BLOCK_STRUCT_PTR block_ptr; &lt;/STRONG&gt;which contains the owner task number. However, this information is internal, you may need either to reproduce all the private structures in your application or modify BSP to save the task number that called the mem_alloc() and make it readable for your application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Carlos&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Apr 2016 00:27:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Allocation-in-system-memory/m-p/465542#M15532</guid>
      <dc:creator>Carlos_Musich</dc:creator>
      <dc:date>2016-04-13T00:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: Allocation in system memory</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Allocation-in-system-memory/m-p/465543#M15533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually you can see that &lt;STRONG&gt;_lwmem_alloc_internal() &lt;/STRONG&gt; returns the address where block_ptr was created plus the size of this structure.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;retval = (void *) ((unsigned char *) block_ptr + sizeof(LWMEM_BLOCK_STRUCT));&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This means that if you substract manually from the memory pointer the sizeof(LWMEM_BLOCK_STRUCT)) you will get the block starting address and you only need calculate the address of bloct_ptr-&amp;gt; U-&amp;gt;S-&amp;gt;TASK_NUMBER&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Carlos&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Apr 2016 20:37:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Allocation-in-system-memory/m-p/465543#M15533</guid>
      <dc:creator>Carlos_Musich</dc:creator>
      <dc:date>2016-04-13T20:37:43Z</dc:date>
    </item>
  </channel>
</rss>

