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.

Another Syslink bug?

When does Sylink/Ipc call MessageQ_free()?  I had assumed that I should be pairing calls to MessageQ_free() with calls to MessageQ_alloc().  As an experiment, I commented-out my calls to MessageQ_free() on the host-side, yet I still see calls being made to MessageQ_free() on the DSP-side.  In fact, Syslink attempted to free the same message twice, before it was used, resulting in an assertion error:

ti.sdo.ipc.MessageQ: line 260: assertion failure: A_heapIdInvalid: heapId is invalid

xdc.runtime.Error.raise: terminating execution

I have written a program that creates three message queues on the DSP, one message queue for each of three tasks, and messages are made by the host and sent to the DSP.

I'm using the DM8168 DDR3 EVM with Syslink 2.00.00.78 and IPC 1.23.02.27.

Lee Holeva

 

  • Quick rule of thumb:

    • Sender calls alloc() and put()
    • Receiver calls get() and free()

    If Sender/Receiver are on different processors, the 'heap' being used must be of the "MP" variety (e.g. HeapBufMP) so that one side can alloc and the other can free.

    For extra credit...

    In some use cases, rather than freeing the message the 'receiver' re-uses the same message to 'reply to sender'.  In those case, the 'receiver' neither allocs nor frees, it just calls get/put.  And the 'sender' then calls alloc/put/get/free.  I say this not to confuse, but to explain how, in some use cases, the 'heap' being used isn't _really_ alloc/free from different processors, and can therefore sometimes _not_ be of the "MP" variety.

    Chris

  • Chris Ring said:

    Quick rule of thumb:

    • Sender calls alloc() and put()
    • Receiver calls get() and free()

    If Sender/Receiver are on different processors, the 'heap' being used must be of the "MP" variety (e.g. HeapBufMP) so that one side can alloc and the other can free.

    Ok, I rewrote my code to adhere to the above rules, but I'm having problems with MessageQ_free().  If I comment-out all calls to MessageQ_free() the code works fine, however, upon putting a breakpoint at line 260 in MessageQ.c, within MessageQ_free(), I observe multiple hits to the breakpoint, looking like an attempt is made to free the same message more than once and an error assertion follows.

    Update:

    I put the MessageQ_free()s back with the host, none on the DSP, and the code ran fine.  There seems to be an issue doing MessageQ_free() on the DSP.  I haven't tried doing 2-way messaging yet, so we'll see how that goes.  I have a semaphore on the host synchronizing the DSP's tasking and after the semaphore I do the message freeing.  The basic host-side code is then:

    Osal_printf("Opening the DSP's message queue\n");
        do {
          status = MessageQ_open (msgqName, &rqId);
        } while (status == MessageQ_E_NOTFOUND);

    msg = MessageQ_alloc(heapId, msgLength+sizeof(MessageQ_MsgHeader));

    Osal_printf("Sending a message to the DSP\n");
          status = MessageQ_put(rqId, msg);

    status = MessageQ_close (&rqId);

     status = Notify_sendEvent (procId,
                                     DODSPTASK_LINEID,
                                     taskId,
                                     0,
                                     TRUE);
      } while ((status == Notify_E_NOTINITIALIZED)
                  ||(status == Notify_E_EVTNOTREGISTERED)
                  ||(status == Notify_E_EVTDISABLED));

    OsalSemaphore_pend (syncsemH, OSALSEMAPHORE_WAIT_FOREVER);
        Osal_printf("Freeing message for task %d\n", taskId);
        MessageQ_free(msg);

     

     

    Lee Holeva