ucos-2.86以及以前版本在cortex-m3上面有这个bug。
要改os_core.c里面OS_Sched和OS_IntExit两个函数。
注意OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy];的位置。
只要把这句话提前一行就行了。
- void OS_Sched (void)
- {
- #if OS_CRITICAL_METHOD == 3u /* Allocate storage for CPU status register */
- OS_CPU_SR cpu_sr = 0u;
- #endif
- OS_ENTER_CRITICAL();
- if (OSIntNesting == 0u) { /* Schedule only if all ISRs done and ... */
- if (OSLockNesting == 0u) { /* ... scheduler is not locked */
- OS_SchedNew();
- OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy];
- if (OSPrioHighRdy != OSPrioCur) { /* No Ctx Sw if current task is highest rdy */
- #if OS_TASK_PROFILE_EN > 0u
- OSTCBHighRdy->OSTCBCtxSwCtr++; /* Inc. # of context switches to this task */
- #endif
- OSCtxSwCtr++; /* Increment context switch counter */
- OS_TASK_SW(); /* Perform a context switch */
- }
- }
- }
- OS_EXIT_CRITICAL();
- }
|