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.

MSGQ Example

 

I was wondering what is keeping me from using a message structure bigger than MSGQ_MsgHeader + 40 bytes in the task2task example from the 5_41_10_36 DSP BIOS.    I would like to have at least 5 messages with the following structure. Is the buffer just raw data to be structured any way I want?

 

typedef struct MyMsg {

Uint8  byte1;

Uint8  byte2;

Uint8  byte3;

Uint8  byte4;

Uint32  uint32_1;

Uint8  byte_array1[255];

Uint8  byte5;

} MyMsg;

 

Thanks,

-Mike

  • Hi Mike,

    With MSGQ, messages can be of variable size (from sizeof(MSGQ_MsgHeader) to 65535 bytes). The first sizeof(MSGQ_MsgHeader) bytes of a message are used by MSGQ. The header contains things like linked list pointers, sizes, destination, etc.

    For multi-processors systems, some transports might impose additional messages restrictions (i.e. aligned on a cache boundary, size is a multiple of a cacheline size,etc.).

    With the definition of MyMsg you have, bad things will happen if you change byte1-byte4, uint32_1, and the first part of byte_array1. That's why we have examples with the MSGQ_MsgHeader first in the structure definition.

    Note: we could have hidden the MSGQ_MsgHeader before the address returned from MSGQ_alloc. This complicates/confuses things when cache is enabled and alignment and boundaries need to be honored. So we require the user to be aware of the header at the beginning of the message.

    Todd

  • Hi Todd,

    Sorry, I meant to have a MSGQ_MsgHeader in the beginning of the structure.  So a MSGQ_MsgHeader is 20 bytes so my buffer will need to be 20 bytes + data bytes * number of messages rounded up to the next 8 byte boundary?

  • I don't understand the "data bytes * number of messages" portion of your reply. More specifically the usage of the word "messages" is confusing me. Do you mean number of application specific commands?

    Todd

  • The data bytes would be the payload and a message is a payload with the necessary overhead.  In Ti's example a message to me is the entire MyMsg structure and the data bytes would be the Uns sequenceNumber which is made up of 4 bytes.  I'm counting everything in bytes since the buffer is a byte array.

  • What does you POOL configuration look like?

  • Hi Mike,

    What exactly is the problem you are having? Are you trying to change the example's MyMsg structure to be bigger and the MSGQ_alloc is failing? If this is happening, please confirm that you increased the MSGSIZE constant. (I'm not sure why we didn't use sizeof(MyMsg) instead...might have not been legal 'C' code.).

    Todd