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.

DNUM区别多个核的问题



附件中的程序是简单的用DNUM区别多个核,我运行时候很不稳定,有时候1核会跑到2核的部分去,有时候2核跑到1核部分,也有时候能正确。请问这是什么原因呢?

非常感谢!

程序如下:

void main(void) {
    volatile unsigned int start,end,cycle;
    int coreNum;

    if(0==DNUM)
    {
        Core0Ready=1;

        while(!(Core1Ready&Core2Ready))
        {
            asm(" nop");
        }
        TSCL=0;
        start=TSCL;

        while(!(Core1Finish&Core2Finish))
        {
            asm(" nop");
        }

        end=TSCL;
        cycle=end-start;

        while(1)
        {
            asm(" nop");
        }
    }
    
    else if(1==DNUM)
    {
        Core1Ready=1;
        while(!(Core0Ready&Core2Ready))
        {
            asm(" nop");
        }
#pragma MUST_ITERATE(NB,NB);
        for (jjC1=0;jjC1<90;jjC1++)
        {
            printf("Core1: processing %d\n",jjC1);
        }

        while(1)
        {
            asm(" nop");
        }
    }

    else if(2==DNUM)
    {
        Core2Ready=1;
        while(!(Core0Ready&Core1Ready))
        {
            asm(" nop");
        }
#pragma MUST_ITERATE(NB,NB);
        for (jjC2=0;jjC2<90;jjC2++)
        {
            printf("Core2: processing %d\n",jjC2);
        }
        while(1)
        {
            asm(" nop");
        }
    }
}

multicore.rar
  • 我觉得你的cmd文件有问题,每个核除了部分私有数据放在各自L2或者共享memory,其他的代码和堆栈都放在core0的L2。建议修改cmd将代码和堆栈放在各自核的私有L2试试。

  • 这个问题可以解决了,但是现象还是不能理解。

    如果将标志位设置L2中,则运行正常。放在MSMC中则不正常,多个核分别去看这个标志位,虽然地址相同,但是数据却不同,用memory查看也是一样的结果。请问这是怎么回事呢?