void OSIntCtxSw (void)
File | Called from | Code enabled by |
---|---|---|
|
| N/A |
Description
OSIntCtxSw()
is is called from from OSIntExit()
to to perform a context switch when all nested interrupts have returned.
Interrupts are disabled when when OSIntCtxSw()
is is called.
OSTCBCurPtr
points points at the the OS_TCB
of of the task that is switched out when when OSIntCtxSw()
is is called and and OSIntExit()
sets sets OSTCBHighRdyPtr
to to point at the the OS_TCB
of of the task that is switched in.
Files
os.h/os_cpu_a.asm
Prototype
Arguments
None
Returned Values
None
Required Configuration
None
Callers
OSIntExit()
.
Notes/Warnings
None
Example Usage
The pseudocode for OSIntCtxSw()
is shown below. Notice that the code does only half of what OSCtxSw()
did. The reason is that OSIntCtxSw()
is called from an ISR and it is assumed that all of the CPU registers of the interrupted task were saved at the beginning of the ISR. OSIntCtxSw()
therefore must only restore the context of the new, high-priority task.
(1) OSIntCtxSw()
must call OSTaskSwHook()
.
(2) OSPrioHighRdy
needs to be copied to OSPrioCur
.
(3) OSTCBHighRdyPtr
needs to be copied to OSTCBCurPtr
because the current task will now be the new task.
(4) The stack pointer of the new task is restored from the OS_TCB
of the new task.
(5) All the CPU registers need to be restored from the new task’s stack.
(6) A return from interrupt instruction must be executed.