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.

should HeapBufMP_create be in Thread ? why not in main() ?

Other Parts Discussed in Thread: SYSBIOS

Hi All,

             Should HeapBufMP_create be in a thread. I see when i have two cores with core0 doing HeapBufMP_create in main() and after that one of the cores is not crossing the BIOS_start() in the main().

The same HeapBufMP_create if i do in Thread [NOT WITHIN while(1) loop], the core control flow is crossing BIOS_start()

Ti doesn't mention about HeapBufMP_create but it does mention about HeapBufMP_open()

My idea is to not take the headache of HeapBufMP_create in Tasks as i want it to be done once at start [i.e.main()]

please let me know on this

Thanks

R C Reddy

  • RC Reddy,

    Please post BIOS related questions in the BIOS section of the forum.  I've moved this one as I've moved others before.  Postings need to be in the correct place to insure the correct audience and quicker response.

    Best Regards,

    Chad

  • Thanks Chad,

                            I will stick to this protocol from now on. Actually i was under impression that all IPC questions should be to multicore forum, now i understand that they stand with BIOS forums.

    Regards

    RC Reddy

  • Thanks for understanding, I appreciate it.  It's often hard to determine where the support should be from the customer side of things.  Basically if it's BIOS related it needs to go to BIOS, Linux related to Linux, CCS/Emulator Related to CCS, etc.  Even though the device may be C66xx it still goes to those other forums if the question is specific to that area of support for the device.

    Best Regards,

    Chad

  • Hi R C Reddy,

    I hunted through the code a bit and didn't see anything stand out that made me think you couldn't do this at main.  I can ask my colleague about it on Monday for a more concrete answer.  In the meantime ...

    Taking a quick look at the IPC examples, I see that HeapBufMP_create() is called from within task context, but that still doesn't answer your question, as we can't conclude that from this that you can't call it from main().

    For now you may want to assume that it must be called after BIOS_start().  What you can do is try putting your HeapBufMP_create() code into a BIOS startup function.  You can configure a start up function to be called in your *.cfg file with code similar to the following:

    /* get handle to BIOS module */
    var BIOS = xdc.useModule('ti.sysbios.BIOS');
    /* install a BIOS startup function */
    BIOS.addUserStartupFunction('&myBiosStartup');

    "myBiosStartup()" would contain the HeapBufMP_create() call

    Steve

  • Sorry for late reply,

                                    i will provide you the code shortly, please try it at your end and let me know.

    Thanks

    RC Reddy

  • RC,

    The short answer to your question is that HeapBufMP_create() can be called from main() only after Ipc_start()/Ipc_attach().  In fact, you can't call any IPC APIs until you have called Ipc_start();

    Note:  HeapBufMP_open() must be called from a thread because it requires interrupts to be enabled.

    Judah

  • Hi Judah,

                    i see a contradiction in your statement to what Ti mentions in the Ipc.h file. It says IPC_attach has to be in Task() and you say HeapBufMP_create can occur only after IPC_attach, so it boils down to "HeapBufMP to be created in Task()". 

    Please clarify 

    ==================================================================

    /*!
    * @brief Attach to remote processor
    *
    * This function uses shared memory to synchronize self with the remote
    * processor. Both processors must call this function to attach to each
    * other. Ipc_start() must be called before calling Ipc_attach().
    * A processor must attach to the owner of SharedRegion zero before
    * it can successfully attach to another processor. Attempting to
    * attach to another processor first returns #Ipc_E_FAIL.
    *
    * This function opens the default GateMP and SharedRegion zero heap.
    * The Notify, NameServerRemoteNotify, and MessageQ transport
    * instances are created for communicating with the specified remote
    * processor in SharedRegion zero heap. The user's Ipc attach function
    * is called.
    *
    * For BIOS, this function should be called within a 'while' loop
    * within a Task. A Task_sleep() or Task_yield() should be called
    * within the loop to allow other threads in the system to execute.
    * This function needs to be called in a loop because the remote
    * processor may not be in a ready state.
    *
    * Note: For BIOS, if the config parameter Ipc.procSync is set to
    * Ipc.ProcSync_ALL, there is no need to call this function as it is
    * internally called by Ipc_start().
    *
    * @code
    * while (Ipc_attach(remoteProcId) < 0) {
    * Task_sleep(1);
    * }
    * @endcode
    *
    * @param remoteProcId remote processor's MultiProc id
    *
    * @return Status
    * - #Ipc_S_SUCCESS: attach was successful
    * - #Ipc_S_ALREADYSETUP: already attached
    * - #Ipc_E_MEMORY: operation failed due to a memory error
    * - #Ipc_E_FAIL: General failure
    * - #Ipc_E_NOTREADY: remote processor not ready
    *
    * @sa Ipc_detach Ipc_isAttached
    */
    Int Ipc_attach(UInt16 remoteProcId);

    =======================================================

    Thanks

    RC Reddy

  • RC,

    If you are explicity calling Ipc_attach() then yes, it should be called in a Task.

    If you are simply calling Ipc_start() (this will call Ipc_attach() for you) and synchronizing all the processors then you can call this in main().

    That's why I said Ipc_start()/Ipc_attach().  Its really not a contradiction, it just depends on how you want to synchronize the processors.

    Judah 

  • So i will conclude like this

    1. If its all cores, which has tobe synchronized then IPC_START (which is enoff for all cores to get synched), then i can do HeapBufMP_create in main() itself.

    2. if its only few cores [NOT ALL Cores] [synching through IPC_attach only], then HeapBufMP_create HAS to be CREATED in a task.

    Thanks

    RC Reddy

  • Sure that sounds correct.