Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

faster memory allocation/freeing

$
0
0

Hi All,

         As part of IPC UG, i came across this statement.

""The HeapBufMP manager is intended as a very fast memory manager which can only allocate blocks of a single size"". 

From my understanding of Ti ipc examples, let me put in points.

1. If a sharedRegion is created, by default a HeapMemMP instance is associated with it. ["It creates a HeapMemMP instance which spans the full size of the region. The other processors open the same HeapMemMP instance."]

2. For using across Multiple cores [i.e. doing a malloc across multiple cores], a single instance is enoff right. In other words, i will use the heap handle of HeapMemMp [i.e gotten through sharedregion_getheap()...so this will give a heap handle and it can be used by all cores]. 

Ptr Osal_cppiMalloc (UInt32 num_bytes)
{
Error_Block errorBlock;

/* Allocate memory. */
Error_init(&errorBlock);
cppiMallocCounter++;

/* Allocate a buffer from the default HeapMemMp */
return Memory_alloc (SharedRegion_getHeap(0), num_bytes, 0, &errorBlock);
}

please note i am using the ALREADY CREATED HeapMemMp instance created by SharedRegion. 

3. Similar to step 2, i want to create a HeapBufMp instance out of a shared Region. I saw an example on that in consumer_srio.c

if (selfId == 0)
{
/* Create the heap that will be used to allocate messages. */
HeapBufMP_Params_init(&heapBufParams);
heapBufParams.regionId = 0; //sharedRegionId
heapBufParams.name = HEAP_NAME;
heapBufParams.numBlocks = NUM_HOST_DESC;
heapBufParams.blockSize = SRIO_MTU_SIZE;
heapHandle = HeapBufMP_create(&heapBufParams);
if (heapHandle == NULL)
{
System_abort("HeapBufMP_create failed\n" );
}
}
else
{
/* Open the heap created by the other processor. Loop until opened. */
do
{
status = HeapBufMP_open(HEAP_NAME, &heapHandle);
} while (status < 0);
}

[A]. Is the above method/way correct way to create HeapBufMP handle. Can i dictate sharedRegion to create default HeapBufMP instance instead of HeapMemMp instance ??

[B]. Do i need to call HEapBufMP_Open function mandatorily. looks like each core is having its own handle of the HeapBufMp is this correct. why can't there be global handle i.e. [heapHandle] ?

[c] Point me to an example, where there is no open [HEapBufMP_Open] called in each core, only one global handle created by one core and used by all cores [since handle is nothing but a structure, why should there be multiple handles in each core, there can be one global handle].

Thanks

RC Reddy


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>