Checkpointing while context switching