运行结果如下:
主要代码:
Void tsk0_func(UArg arg0, UArg arg1)
{
Int status;
Int i;
int coreId=MultiProc_self();
// 分配内存
if (coreId == 0) {
inBuf = (unsigned char*)Memory_alloc(SharedRegion_getHeap(0), dateNum, 128, NULL);
if(inBuf==NULL)
{
System_printf("malloc Buf failed\n");
BIOS_exit(0);
}
for(i=0;i<dateNum;i++){ // 写入数据
inBuf[i]=i*3+5;
}
inBuf_srptr = SharedRegion_getSRPtr(inBuf, 0);
System_printf("inBuf address 0x%x\n",inBuf);
System_printf("outBuf date is ");
for(i=0;i<dateNum;i++)
System_printf("%d ",inBuf[i]);
System_printf("\n");
Cache_wbAll();// Write back all caches();
for(i=1;i<8;i++)
status = Notify_sendEvent(i, INTERRUPT_LINE, BufEVENT, (UInt32)inBuf_srptr, TRUE);
/* Wait to be released by the cbFxn posting the semaphore */
Semaphore_pend(semHandle, BIOS_WAIT_FOREVER); // 主核等待所有从核完成其工作返回
Cache_wbAll();// Write back all caches();
System_printf("MasterCore Received Event from All SloverCores,Data:\n");
for(i=0;i<dateNum;i++)
System_printf("%d ",inBuf[i]);
System_printf("\n");
}else{
Semaphore_pend(semHandle, BIOS_WAIT_FOREVER); // 等待从核完成全部任务
Cache_disable(Cache_Type_ALL);
inBuf=SharedRegion_getPtr(inBuf_srptr);
inBuf[coreId ]=coreId*coreId ;
Cache_wbAll();// Write back all caches();
System_printf("inBuf address 0x%x\n",inBuf);
System_printf("regionId is %d\n",SharedRegion_getId(inBuf)); // 打印当前共享区域ID
System_printf("outBuf date is ");
for(i=0;i<dateNum;i++)
System_printf("%d ",inBuf[i]);
System_printf("\n");
/* Send an event to the next processor */
status = Notify_sendEvent(masterProc, INTERRUPT_LINE, BufEVENT, (UInt32)inBuf_srptr, TRUE);
}
// 各核完成任务后可以退出了
System_printf("SharedMem is finished\n");
BIOS_exit(0);
}
想用从核改写共享内存中的数据之后,主核利用改写过的数据继续执行。现在主核的数据并没有刷新,还是原来写进去的。
非常希望收到回复,感谢各位指教。谢谢