To demonstrate the context switching operation in a real example, here we use a simple task scheduler that switches between four tasks in a round robin arrangement. If multiple LEDs are available, each of the tasks toggles one of the LED at different speed.
The context switching operation is carried out by the PendSV exception handler. Since the exception sequence already saved registers R0–R3, R12, LR, Return Address and xPSR, the PendSV only needs to store R4–R11 to the process stack (Figure 10.15
The code for the project can be implemented ...