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.

Notify Events in c6678

Hi All !

I use Notify_multicore example from ipc_1_22_05_27. But in my case CORE1, CORE2 and CORE3 must send Notify Events to CORE0. And CORE0 does some things in the callback function.So, CORE1, 2, 3 are interrupting CORE0, but CORE0 continues a main loop after executing the callback function.

My code is:

/* Notify Event is registered in CORE1, CORE2 and CORE3 */

Int main(Int argc, Char* argv[])
{
    Int status;
    UInt numProcs = MultiProc_getNumProcessors();

    status = Ipc_start();
    if (status < 0)   System_abort("Ipc_start failed\n");


    if (MultiProc_self() == 0)
    {
        int i;
        for (i = 0; i < numProcs-1; i++)
        {
            srcProcs[i] = i+1;

            status = Notify_registerEvent(srcProcs[i], INTERRUPT_LINE, EVENTID, (Notify_FnNotifyCbck)cbFxn, NULL);
            if (status < 0)  System_abort("Notify_registerEvent failed\n");           
        }
    }
    else dstProc = 0;
   
    BIOS_start();

    return (0);
}

Void cbFxn(UInt16 procId, UInt16 lineId, UInt32 eventId, UArg arg, UInt32 payload)
{
    /* Do some things.... */


    Semaphore_post(semHandle);
}

Void tsk0_func(UArg arg0, UArg arg1)
{   
    Int status;

    if (MultiProc_self() == 0)
    {     
        /* The Main Loop... */

       // ............
    }
    else {
        while (1) {

           // Do some things....


           seq++;
            status = Notify_sendEvent(dstProc, INTERRUPT_LINE, EVENTID, seq, TRUE);
            if (status < 0)  System_abort("sendEvent failed\n");
                       
            Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);
        }
    }

    System_printf("Test completed\n");
    System_exit(0);
}

This code doesn't work! CORE1, CORE2 and CORE3 send Notify Events to CORE0 and then COREs 1,2, 3 freeze on Semaphore_pend. But CORE0 passes cbFxn(...) function three times and does Semaphore_post().

Probably I don't understand conсept of semaphores.  What's wrong in my code ?

  • Andrey,

    Those Semaphores are local only.  They don't go across cores.

    The cores 1, 2, 3 that call Sempahore_pend(), what are they waiting for?  Are they waiting for Core 0 to complete something first?  If so, once Core0 does its thing, it should send a notification back to cores 1, 2, 3 and then in their callbacks they should do a Semaphore_post().

    Judah

  • Thank you for your post!

    Is there any Semaphore in SYS/BIOS which can goes across cores ? Just It was an attempt using Semaphore across cores to avoid the situation when two or three cores (CORE1, 2, 3) send Notify Event to CORE0 at the same time. Is there event queue for the case like this ? What happens if a few events are sent to CORE0 at the same time? If nothing bad happens then I don't need semaphores.

      In my application CORE0 reads data (time to time) from GPIO pins. So CORE0 must not be interrupted during the reading process. As far as I understood the SPRUGO6C document on IPC I can use Notify_disableEvent() and Notify_restore() for this goal. If Notification Events are disabled in COE0, then CORE1, 2, 3 send Events, but CORE0 is not interupting. Am I right ? Just unfortunately, I cannot check it right now.

    Thanks !

  • Andrey,

    There are no Semaphores that go across cores.  Multiple notifications can occur at the same time.  What you might want to do is have each of those notifications on a different notify event, that way if all cores send a notification at the same time, the receiving core doesn't think its all the same event.

    I think if you want to disable the Interrupt line use Notify_disable() not Notify_disableEvent().  Notify_disableEvent() is meant to disable just a single notify event not the interrupt line.

    Judah