Hi,
If I want to use MessageQ and send a pointer to data together with the message I do something like:
Create the structure:
typedef struct
{
MessageQ_MsgHeader header;
dataType *dataPtr;
} DataMsg;
And in the core (supposing the heap has already been created, opened and the MessageQ registered with it):
dataMsg1 = (DataMsg *) MessageQ_alloc(HEAPID, sizeof(DataMsg));
dataMsg1->dataPtr = (dataType *) HeapBufMP_alloc(heapHandle, sizeof(dataType), align);
My questions are:
1 - I have to do a MessageQ_alloc in every core in which I want to use the message. Should I do a HeapBufMP_alloc to allocate memory for the pointer in all cores too?
2 - If I do HeapBufMP_alloc in all cores, the pointer that is returned will be the same in all cores, in the case that it is in shared memory?
3 - If I do an alloc() I have to do a free(), but if the pointers returned by HeapBufMP_alloc were the same I'd have a problem of freeing a memory region that has already been freed, wouldn't I?
Thanks