You would do it the same way as on any other platform: you save the contents of the corresponding registers:
- stack pointer
- instruction pointer
- depending on which general purpose registers are suitable for the architecture
- any other state that needs to be maintained (FPU / MMX / SSE registers, etc.).
for the task you are switching from and restore it for the task you are switching to.
Often this is done by pushing the entire state onto the stack from which you are switching, and pushing it from the stack to which you are switching. Thus, only the stack pointer should be passed on or managed by the kernel to track pending in the background.
Adam maras
source share