TI中文支持网
TI专业的中文技术问题搜集分享网站

C6678 IPC Notify

您好:代码如下

void *threadFxn(void *arg);

void cbFxn(UInt16 procId, UInt16 lineId, UInt32 eventId, UArg arg, UInt32 payload) {

              Semaphore_post(semHandle);

}

void *tsk_func(void *arg)

{

    int status;

    if (MultiProc_self() == 0) {

//****************************************************************

               /*这里可以添加主核需要执行的任务代码*/

                  pthread_t thread;

                  pthread_attr_t attr;

                  size_t stacksize = 0x400000;//4MB

                  pthread_attr_init(&attr);

                  pthread_attr_setstacksize(&attr,stacksize);

                  if( pthread_create(&thread,&attr,threadFxn,NULL) )

                  {

                         thread = 0;

                         System_abort("create thread failed\n");

                  }

//*****************************************************************

            /* Send an event to the next processor */

            status = Notify_sendEvent(1, 0, 10, NULL, TRUE);

            if (status < 0) {

                System_abort("Notify_sendEvent for slaveCore1 failed\n");

            }

            /* Send an event to the next processor */

            status = Notify_sendEvent(2, 0, 10, NULL, TRUE);

            if (status < 0) {

                System_abort("Notify_sendEvent for slaveCore2 failed\n");

            }

            /* Send an event to the next processor */

            status = Notify_sendEvent(3, 0, 10, NULL, TRUE);

            if (status < 0) {

                System_abort("Notify_sendEvent for slaveCore3 failed\n");

            }

            /* Send an event to the next processor */

            status = Notify_sendEvent(4, 0, 10, NULL, TRUE);

            if (status < 0) {

                System_abort("Notify_sendEvent for slaveCore4 failed\n");

            }

            /* Send an event to the next processor */

            status = Notify_sendEvent(5, 0, 10, NULL, TRUE);

            if (status < 0) {

                System_abort("Notify_sendEvent for slaveCore5 failed\n");

            }

            /* Send an event to the next processor */

            status = Notify_sendEvent(6, 0, 10, NULL, TRUE);

            if (status < 0) {

                System_abort("Notify_sendEvent for slaveCore6 failed\n");

            }

            /* Send an event to the next processor */

            status = Notify_sendEvent(7, 0, 10, NULL, TRUE);

            if (status < 0) {

                System_abort("Notify_sendEvent for slaveCore7 failed\n");

            }

            /* Wait to be released by the cbFxn posting the semaphore */

            Semaphore_pend(semHandle, BIOS_WAIT_FOREVER); // 主核等待从核完成其工作返回

            System_printf("MasterCore0 Received Event from All SloverCores\n");

 疑问:主核在等待从核完成任务的时候被挂起,再从核执行完之后,不是应该返回这里,但是核0并没有打印这条信息,而是直接进入创建的线程。

    }

    else {

            /* wait forever on a semaphore, semaphore is posted in callback */

            Semaphore_pend(semHandle, BIOS_WAIT_FOREVER); // 等待主核通知开始执行任务

            System_printf("SlaverCore%d Received Event from MasterCore0\n", MultiProc_self());

疑问:为什么这里MultiProc_self()得到的是同一个核的ID,而不是执行这段代码的核的ID

//****************************************************************

            /*这里可以添加从核执行的任务*/

                  pthread_t thread;

                  pthread_attr_t attr;

                  size_t stacksize = 0x400000;//4MB

                  pthread_attr_init(&attr);

                  pthread_attr_setstacksize(&attr,stacksize);

                  if( pthread_create(&thread,&attr,threadFxn,NULL) )

                  {

                         thread = 0;

                         System_abort("create threadMain failed\n");

                  }

//*****************************************************************

            /* Send an event to the next processor */

            status = Notify_sendEvent(0, 0, 10, NULL, TRUE);

            if (status < 0) {

                System_abort("sendEvent to MasterCore0 failed\n");

            }

            System_printf("SlaverCore%d sent Event to MasterCore0 \n", MultiProc_self());

    }

    return (void*)0;

}

void *threadFxn(void *arg)

{

    System_printf("Core%d enter thread\n", MultiProc_self());

    System_printf("Test over\n");

    BIOS_exit(0);

    return (void*)0;

}

int main()

{

    int status;

    status = Ipc_start();

    if (status < 0) {

        System_abort("Ipc_start failed\n");

    }

    System_printf("Ipc_start successfully\n");

 

    pthread_t tsk;

    pthread_attr_t attr;

    size_t stacksize = 0x400000;//4MB

    pthread_attr_init(&attr);

    pthread_attr_setstacksize(&attr,stacksize);

    if(pthread_create(&tsk,&attr,tsk_func,NULL))

    {

       tsk = 0;

       System_abort("create tsk failed\n");

    }

    if(MultiProc_self() == 0)//0是主核,1-7是从核

    {

           do{

                  status = Ipc_attach(1);

           }while(status < 0);// 完成从核1的连接

       do{

              status = Ipc_attach(2);

       }while(status < 0);// 完成从核2的连接

       do{

              status = Ipc_attach(3);

       }while(status < 0);// 完成从核3的连接

       do{

              status = Ipc_attach(4);

       }while(status < 0);// 完成从核4的连接

       do{

              status = Ipc_attach(5);

       }while(status < 0);// 完成从核5的连接

       do{

              status = Ipc_attach(6);

       }while(status < 0);// 完成从核6的连接

       do{

              status = Ipc_attach(7);

       }while(status < 0);// 完成从核7的连接

 

        status = Notify_registerEvent(1, 0, 10, (Notify_FnNotifyCbck)cbFxn, NULL);

        if (status < 0) {

            System_abort("Notify_registerEvent for slaveCore1 failed\n");

        }// 完成从核1的事件注册

        status = Notify_registerEvent(2, 0, 10, (Notify_FnNotifyCbck)cbFxn, NULL);

        if (status < 0) {

            System_abort("Notify_registerEvent for slaveCore2 failed\n");

        }// 完成从核2的事件注册

        status = Notify_registerEvent(3, 0, 10, (Notify_FnNotifyCbck)cbFxn, NULL);

        if (status < 0) {

            System_abort("Notify_registerEvent for slaveCore3 failed\n");

        }// 完成从核3的事件注册

        status = Notify_registerEvent(4, 0, 10, (Notify_FnNotifyCbck)cbFxn, NULL);

        if (status < 0) {

            System_abort("Notify_registerEvent for slaveCore4 failed\n");

        }// 完成从核4的事件注册

        status = Notify_registerEvent(5, 0, 10, (Notify_FnNotifyCbck)cbFxn, NULL);

        if (status < 0) {

            System_abort("Notify_registerEvent for slaveCore5 failed\n");

        }// 完成从核5的事件注册

        status = Notify_registerEvent(6, 0, 10, (Notify_FnNotifyCbck)cbFxn, NULL);

        if (status < 0) {

            System_abort("Notify_registerEvent for slaveCore6 failed\n");

        }// 完成从核6的事件注册

        status = Notify_registerEvent(7, 0, 10, (Notify_FnNotifyCbck)cbFxn, NULL);

        if (status < 0) {

            System_abort("Notify_registerEvent for slaveCore7 failed\n");

        }// 完成从核7的事件注册

        System_printf("Notify_registerEvent for slaveCores successfully\n");

    }

    else{

           do{

                  status = Ipc_attach(0);

           }while(status < 0);// 完成主核0的连接

 

        status = Notify_registerEvent(0, 0, 10, (Notify_FnNotifyCbck)cbFxn, NULL);

        if (status < 0) {

            System_abort("Notify_registerEvent for masterCore0 failed\n");

        }// 完成主核0的事件注册

        System_printf("Notify_registerEvent for masterCore0 successfully\n");

    }

    BIOS_start();

    return 0;

}

测试结果:

 [C66xx_7] Ipc_start successfully
Notify_registerEvent for masterCore0 successfully
SlaverCore4 Received Event from MasterCore0
SlaverCore7 sent Event to MasterCore0 
Core7 enter thread
Test over
[C66xx_0] Ipc_start successfully
Notify_registerEvent for slaveCores successfully
//这里不是应该再从核完成之后返回主核之后,打印一条信息,在进入创建的线程的吗
Core0 enter thread
Test over
[C66xx_1] Ipc_start successfully
Notify_registerEvent for masterCore0 successfully
SlaverCore4 Received Event from MasterCore0
SlaverCore1 sent Event to MasterCore0 
Core1 enter thread
Test over
[C66xx_2] Ipc_start successfully
Notify_registerEvent for masterCore0 successfully
SlaverCore4 Received Event from MasterCore0
SlaverCore2 sent Event to MasterCore0 
Core2 enter thread
Test over
[C66xx_3] Ipc_start successfully
Notify_registerEvent for masterCore0 successfully
SlaverCore4 Received Event from MasterCore0
SlaverCore3 sent Event to MasterCore0 
Core3 enter thread
Test over
[C66xx_4] Ipc_start successfully
Notify_registerEvent for masterCore0 successfully
SlaverCore4 Received Event from MasterCore0
SlaverCore4 sent Event to MasterCore0 
Core4 enter thread
Test over
[C66xx_5] Ipc_start successfully
Notify_registerEvent for masterCore0 successfully
SlaverCore4 Received Event from MasterCore0
SlaverCore5 sent Event to MasterCore0 
Core5 enter thread
Test over
多次测试,也没有找出原因,希望得到您的帮助,另外请问这个测试代码写的有没有其他问题,谢谢!
Shine:

先只用两个核呢?如只有core0, core1 核间通信,看是否也有一样的问题。

qq z:

回复 Shine:

您好,core0和core1的测试情况是这样的: 

 [C66xx_2] ti.sdo.ipc.family.c647x.MultiProcSetup: line 62: assertion failure: A_invalidProcessor: This core is not present in the MultiProc name listxdc.runtime.Error.raise: terminating execution[C66xx_3] ti.sdo.ipc.family.c647x.MultiProcSetup: line 62: assertion failure: A_invalidProcessor: This core is not present in the MultiProc name listxdc.runtime.Error.raise: terminating execution[C66xx_4] ti.sdo.ipc.family.c647x.MultiProcSetup: line 62: assertion failure: A_invalidProcessor: This core is not present in the MultiProc name listxdc.runtime.Error.raise: terminating execution[C66xx_5] ti.sdo.ipc.family.c647x.MultiProcSetup: line 62: assertion failure: A_invalidProcessor: This core is not present in the MultiProc name listxdc.runtime.Error.raise: terminating execution[C66xx_6] ti.sdo.ipc.family.c647x.MultiProcSetup: line 62: assertion failure: A_invalidProcessor: This core is not present in the MultiProc name listxdc.runtime.Error.raise: terminating execution[C66xx_7] ti.sdo.ipc.family.c647x.MultiProcSetup: line 62: assertion failure: A_invalidProcessor: This core is not present in the MultiProc name listxdc.runtime.Error.raise: terminating execution[C66xx_0] Ipc_start successfullyNotify_registerEvent for slaveCores successfullyCore0 enter threadTest over[C66xx_1] B13=0x0B14=0x920bbb4c B15=0x80400478B16=0x4 B17=0x0B18=0x3a B19=0x64B20=0x8 B21=0x0B22=0xffffffff B23=0x10000B24=0x20001210 B25=0x80002053B26=0x1001 B27=0x24204B28=0x220000 B29=0x42000048B30=0xc000600 B31=0x2NTSR=0x1000fITSR=0x0IRP=0x0SSR=0x0AMR=0x0RILC=0x0ILC=0x0Exception at 0x0EFR=0x2 NRP=0x0Internal exception: IERR=0x1Instruction fetch exceptionti.sysbios.family.c64p.Exception: line 256: E_exceptionMax: pc = 0x00000000, sp = 0x80400478.xdc.runtime.Error.raise: terminating execution

赞(0)
未经允许不得转载:TI中文支持网 » C6678 IPC Notify
分享到: 更多 (0)