OSCtxSw()
(see os_cpu_a.asm
) is called when the task level scheduler (OSSched()
) determines that a new high priority task needs to execute. The figure below shows the state of several µC/OS-III variables and data structures just prior to calling OSCtxSw()
.
(1) (2) (3) (4) When µC/OS-III creates or suspends a task, it always leaves the stack frame to look as if an interrupt just occurred and all the registers saved onto it. This represents the expected state of the task so it can be resumed. (5) The CPU’s stack pointer points within the stack area (i.e., RAM) of the task that called |
The figure below shows the steps involved in performing the context switch as implemented by OSCtxSw()
.
(1) (2) (3) (4) Finally, |