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.

what is meaning of the Mailbox_Params.heap?

Other Parts Discussed in Thread: SYSBIOS

when create the mailbox using Mailbox_create(4, 50, &mboxParams, &eb); what is the meaning of the mboxParams.heap?

  • When dynamically creating a Mailbox, the heap parameter allows you to specify a specific heap instance from which the memory for the internal mailbox buffers gets allocated. If you leave it NULL, it will use the default system heap.

    Internally, the Mailbox calls Memory_alloc() with the value of mboxParams.heap being passed in as the first argument.

    Whitney

  • Whitney:

    thanks for your reply. I want to know whether the buf, bufsize is the same meaning. just a global buffer (like the data array) could be used for the internal mailbox buffers, not a heap? and if I set both the heap parameter and buf parameter, which one is active? 

  • Whitney:

    another, what is value the bufsize should be? for example, I want to use Mailbox_create(4, 50, &mboxParams, &eb); to create the mailbox with 50 msg, 4 byte each msg, then I do :

    char testdata[200];

    mboxParams.buf = testdata;

    mboxParams.bufsize = 200; 

    but  exception to say, bufsize is too small.   how should the bufsize be set?

  • Mailbox only allocates memory if buf is NULL, so if you give it values for both heap and buf, the heap value will not be used.

    bufSize needs to be bigger than just numMsgs * msgSize to allow space for some header information. It actually needs to be greater than or equal to numMsgs * (msgSize + sizeof(Mailbox_MbxElem)). I would suggest looking at the SYS/BIOS API Reference (there's a link to it in the CCS Help Contents window) section on Mailbox. Here's what it says about the buf parameter.

    This property is only used for dynamically created Mailboxes. If set to 'null', the messages will be allocated from the heap during runtime, otherwise the user may set this to a buffer of their creation to be used for allocating the messages.

    The module will split the buf into ti.sysbios.knl.Mailbox.numMsgs number of blocks (one block per Mailbox message).

    Please note that if the buffer is user supplied, then it is the user's responsibility to ensure that it is aligned properly and is also large enough to contain ti.sysbios.knl.Mailbox.numMsgs number of blocks. The size of each block is defined as follows:

    sizeof(Mailbox_MbxElem) + msgSize

    Since the buffer must be a aligned properly, it may be necessary to 'round up' the total size of the buffer to the next multiple of the alignment for odd sized messages.

    Whitney