OSStartHighRdy
Description
OSStartHighRdy()
is responsible for starting the highest-priority task that was created prior to calling OSStart()
. OSStartHighRdy()
is a µC/OS-III port function that is generally written in assembly language.
Files
os.h/os_cpu_a.asm
Prototype
void OSStartHighRdy (void)
Arguments
None
Returned Values
None
Required Configuration
None
Callers
OSStart()
.
Notes/Warnings
None
Example Usage
The pseudocode for OSStartHighRdy()
is shown below.
OSStartHighRdy: OSTaskSwHook(); (1) SP = OSTCBHighRdyPtr->StkPtr; (2) Pop CPU registers off the task's stack; (3) Return from interrupt; (4)
(1) OSStartHighRdy()
must call OSTaskSwHook()
.
When called, OSTCBCurPtr
and OSTCBHighRdyPtr
both point to the OS_TCB
of the highest-priority task created.
OSTaskSwHook()
should check that OSTCBCurPtr
is not equal to OSTCBHighRdyPtr
as this is the first time OSTaskSwHook()
is called and there is not a task being switched out.
(2) The CPU stack pointer register is loaded with the top-of-stack (TOS) of the task being started. The TOS is found in the .StkPtr
field of the OS_TCB
. For convenience, the .StkPtr
field is the very first field of the OS_TCB
data structure. This makes it easily accessible from assembly language.
(3) The registers are popped from the task’s stack frame. Recall that the registers should have been placed on the stack frame in the same order as if they were pushed at the beginning of an interrupt service routine.
(4) You must execute a return from interrupt. This starts the task as if it was resumed when returning from a real interrupt.