RTOS Context Switch – Step 5
The TaskB stack pointer is retrieved
The TaskB context must be restored. The first thing RTOS macro portRESTORE_CONTEXT does is retrieve the TaskB stack pointer from the copy taken when TaskB was suspended. The TaskB stack pointer is loaded into the processor stack pointer, so now the AVR stack points to the top of the TaskB context.