I am trying to get multiple tasks working with a MessageQ created on Core0 using a heap created in shared memory. This has already been implemented with a working MessageQ between Core0 and Core1. Core1 has a single task that uses the MessageQ between core0 and core1. The Shared MQ Heap is created on Core0 and then opened in Core1 without any problems when only that one task is running on core1. The issue I am having is I am trying to create a second task on Core1 that uses quite a few large mallocs/callocs. In order to get the mallocs and callocs to run in the task I created a Default heap entry to use DDR memory. This task when running alone on Core1 also works fine by itself. As soon as I try to run both tasks and perform any mallocs or callocs it causes the MessageQ heap to not open.
This raises the first question as to are memory allocs thread safe between multiple threads. If multiple threads accessing the default heap in memory are not thread safe is there a way to specify the MessageQ heap_handle to not use the default heap but a second heap I can create in LL2RAM.
This is the excerpt of opening the shared memoryQ on core 1 that fails when we run the second task.
do {
status = HeapBufMP_open("MQHeap", &heap_handle);
} while (status < 0);
// register the heap with message queue
MessageQ_registerHeap((IHeap_Handle)heap_handle, 0);
//MessageQ_registerHeap(SharedRegion_getHeap(0), 0);
The problem I can see is that heap_handle in HeapBufMP_open is getting a handle to our local DDR heap and this call is conflicting with mallocs on the other task. Is it at all possible to have heap_handle use another heap besides the default DDR heap we have create? Or possibly a way to have a separate Default heaps for each individual task running on the same Core?
Any help or ideas to point me in the right direction would be appreciated. I should also mention we are using BIOS 6.31.04.27.
Thanks