OSIntExit ()
{
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr = 0;
#endif
if (OSRunning == OS_TRUE) {
OS_ENTER_CRITICAL();//关中断
if (OSIntNesting > 0) { /* Prevent OSIntNesting from wrapping */
OSIntNesting--;
}
if (OSIntNesting == 0) { /* Reschedule only if all ISRs complete ... */
if (OSLockNesting == 0) { /* ... and not locked. */
OS_SchedNew();
if (OSPrioHighRdy != OSPrioCur) { /* No Ctx Sw if current task is highest rdy */
OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy];
#if OS_TASK_PROFILE_EN > 0
OSTCBHighRdy->OSTCBCtxSwCtr++; /* Inc. # of context switches to this task */
#endif
OSCtxSwCtr++; /* Keep track of the number of ctx switches */
OSIntCtxSw(); /* Perform interrupt level ctx switch */
}
}
}
OS_EXIT_CRITICAL();//开中断
}
}
OSIntCtxSw:
# Call OSTaskSwHook
bl OSTaskSwHook
# Get pointer to ready task TCB
lis r11,OSTCBHighRdyPtr@ha
lwz r11,OSTCBHighRdyPtr@l(r11)
# Save as current task TCB ptr.
lis r12,OSTCBCurPtr@ha
stw r11,OSTCBCurPtr@l(r12)
# Get High Ready Priority
lis r12,OSPrioHighRdy@ha
lbz r10,OSPrioHighRdy@l(r12)
# Save as Current Priority
lis r12,OSPrioCur@ha
stb r10,OSPrioCur@l(r12)