Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The pseudocode for OSStartHighRdy() is shown below.

(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.