...
os.h/os_cpu_a.asm
Prototype
Code Block |
---|
void OSCtxSw (void) |
Arguments
None
Returned Values
...
The pseudocode for OSCtxSw()
follows:
Code Block | ||
---|---|---|
| ||
void OSCtxSw (void)
{
Save all CPU registers; (1)
OSTCBCurPtr->StkPtr = SP; (2)
OSTaskSwHook(); (3)
OSPrioCur = OSPrioHighRdy; (4)
OSTCBCurPtr = OSTCBHighRdyPtr; (5)
SP = OSTCBHighRdyPtr->StkPtr; (6)
Restore all CPU registers; (7)
Return from interrupt; (8)
} |
Panel | ||
---|---|---|
| ||
(1) (2) The current task’s stack pointer is then saved into the current task’s (3) Next, (4) (5) (6) The stack pointer of the new task is restored from the (7) All the CPU registers from the new task’s stack are restored. (8) Finally, |