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 ?