This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Multiple MessageQ_put

Hi,

Is it possible to put some messages without getting them back? Like this:

Core0: get data from peripheral
Core0: put msg with data to core1
Core1: get msg with data and process. doesn't put msg to core0
Core0: get data from peripheral
Core0: put msg with data to core1

When a msg is put the task loses its ownership, so how can I do multiple put's?

Do I have to allocate the message again?

If it's not possible to use MessageQ is there other way to do that?

Thanks for any help.

  • Yes, this is possible. You must call MessageQ_free(msg) to return the message to the heap. So in your case, core1 would call MessageQ_free(msg) after it processed the data.

    Todd

    [edit: corrected API name Message_delete > Message_free]

  • Sorry, I did not answer all the questions.

    Yes, you would need to call MessageQ_alloc again on core0.

    So you have to options

    1. alloc once on core 0 and have core 1 return the message

    2. alloc everytime on core 0 and have core 1 MessageQ_free for each msg.

    Todd

  • Todd,

    Thanks for the answers. Just one more thing, in the case that there's a pointer together with the message I would have to the same (free and alloc), right?

    Regards

  • I'm not quite sure what your question is. Are you asking if there is a pointer inside the message that points to some allocated memory, then yes, you must manage that memory yourself. MessageQ has no knowledge of the actual contents on the message (other than the header). For example

    msg = MessageQ_alloc(...);

    msg->someBlock= Memory_alloc(...)

    Then the receiving side must free the someBlock when it frees the message. Note: on a multi-core system with shared memory, make sure someBlock is in shared memory and you need to perform all the cache coherency as needed.

    Todd

  • Todd,

    You're right, I was talking about the pointer inside the message, like this:

    typedef struct {
        MessageQ_MsgHeader header;
        dataType *dataPtr;
    } MsgName;

    Thanks