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.

C6678 MessagQ

I got mot of the MessageQ code figured out, but can someone explain to me why we need "calloc" in Image processing demo?...Also, "p_queue_msg" is defined as static?...I noticed it is saved in DDR3 but messageQ heap is in shared memory...

int mc_process_init (int number_of_cores)

{

int i;

p_queue_msg = (process_message_t **) calloc(number_of_cores, sizeof(process_message_t *));

if (!p_queue_msg) {

printf("alloc_queue_message: Can't allocate memory for queue message\n");

return -1;

}

for (i = 0; i < number_of_cores; i++) {

p_queue_msg[i] = (process_message_t *) MessageQ_alloc(IMAGE_PROCESSING_HEAPID, sizeof(process_message_t));

if (!p_queue_msg[i]) {

printf("alloc_queue_message: Can't allocate memory for queue message %d\n", i);

return -1;

}

memset(p_queue_msg[i]->info.scratch_buf_len, 0, NUMBER_OF_SCRATCH_BUF * sizeof(uint32_t));

memset(p_queue_msg[i]->info.scratch_buf, 0, NUMBER_OF_SCRATCH_BUF * sizeof(uint8_t *));

}

max_core = number_of_cores;

memset(slave_queue_name, 0, MAX_SLICES*16);

for (i = 0; i < MAX_SLICES; i++) {

GET_SLAVE_QUEUE_NAME(slave_queue_name[i], i);

}

return 0;

}

  • Hi Murad,

    There are many versions of IPC packages.

    Would you please let us know the name of the package you use and the version of it, so that We will check the code snippets you pasted and get back about either "the significance of calloc and static specifiers" or verify whether it is needed or not.

    Regards,

    Shankari

    -------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question.

    --------------------------------------------------------------------------------------------------------

  • Thank you Shankari,

    I am using "ipc_1_24_03_32" and the "image_processing" demo for C6678:
    C:\ti\mcsdk_2_01_02_06\demos\image_processing\ipc\evmc6678l

    Regards,

    Murad
  • Hi Murad,

    Thanks for your info.

    I have looked into the package and these are my observations.

    Murad says said:
     p_queue_msg = (process_message_t **) calloc(number_of_cores, sizeof(process_message_t *));

    This calloc function  will allocate the memory ( number_of_cores x size of process_message_t )  and returns the pointer to the address of the memory allotted to the double pointer,  (i.e.,  p_queue_msg)

    Murad says said:
    static process_message_t ** p_queue_msg = 0;

    p_queue_msg is a global double pointer and as it is static, it will be visible only to that particular file, Mcip_process.c so that if there is any variable of same name in other *.c files, it will not conflict with each other.

    Regards,

    Shankari

    -------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question.

    --------------------------------------------------------------------------------------------------------

  • Thanks Shankari for the prompt reply,
    I guess my question is why do we need to locate the memory twice: once using "calloc" and again using "MessageQ_alloc"...also, I understand that calloc uses different heap (from DDR3 in this example) than MessageQ_alloc (Shared Memory)...why is that needed...the other MessageQ examples only used MessageQ_alloc and I want to make sure I am using it correctly before I send code to customer


    Regards,

    Murad
  • What happened to TI customer service!!!...I used to get replies within a day or two...now I have posts waiting for reply for more than a month...Am I missing anything!!!
  • Hi Murad,

    Sorry for the inconvenience caused due to delay.
    We will look into it and get back soon.

    Regards,
    Shankari
  • Hi Murad,

    I looked into the code

    It seems to me that ...using the Calloc, he is using for allocating array of pointers ; i.e., double pointer. And the messageQ_alloc uses the memory allocated by Calloc and allocates memory of the actual structure, process_message_t for those array of single pointers.

    As per my understanding, there are two points here.

    1. Calloc is allocating the array of pointers one for each core. Calloc uses the DDR3.

    2. MessageQ_allocation will allocate the memory of struct process_message_t for each core and assign it to the double pointer allocated by calloc in the previuos step. MessageQ allocation uses the sharedDRAM.

    3.Calloc uses heap memory only. When we look into the CFG file, it says that the heap memory segment uses the "DDR3". And the message Q allocation uses the shared memory.

    Please refer to the addresses of the array pointers of p_queue_msg[i] in the CCS debug window . Where i is the core number.

     

     

    According to CFG, image_processing_evmc6678l_master.cfg,

    /* Shared Memory base address and length */

    var SHAREDMEM           = 0x0c200000;

    var SHAREDMEMSIZE       = 0x00200000;

    /* Create a Heap. */

    var heapMemParams = new HeapMem.Params();

    heapMemParams.size = 0x8000000;

    heapMemParams.sectionName = "systemHeapMaster";

    Now, we can conclude what I described in the  screenshot matches with the address ranges given in the CFG files.

    Regards,

    Shankari

    -------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question.
    --------------------------------------------------------------------------------------------------------

     

  • Thank you Shankari for the explanation

    Regards,

    Murad