我把uC/OS-II移植到C8051F020上,主函数位
{
hardware_Initial();
OSInit();
......
OSTaskCreate(...);
......
Timer0Init();
OSStart();
}
我是在OSStart之前设置时钟Tick,这样安排合理不?
(2) 初始化中不需使能全局中断?在第一次调用OS_Sched()时会因为进出临界区而打开中断?
OS_ENTER_CRITICAL();
if ((OSIntNesting == 0) && (OSLockNesting == 0)) { /* Sched. only if all ISRs done & not locked */
y = OSUnMapTbl[OSRdyGrp]; /* Get pointer to HPT ready to run */
OSPrioHighRdy = (INT8U)((y << 3) + OSUnMapTbl[OSRdyTbl[y]]);
if (OSPrioHighRdy != OSPrioCur) { /* No Ctx Sw if current task is highest rdy */
OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy];
OSCtxSwCtr++; /* Increment context switch counter */
OS_TASK_SW(); /* Perform a context switch */
}
}
OS_EXIT_CRITICAL(); |