Re:Conceptual question about saving/restoring state.
Transfering data block has no problem using DMA, but before writing data block to SD card, the corresponding command(s) has to be sent first, which might delay some time due to neccessary dummy read involved. I wonder DMA effeciency for SPI data trasaction. However, I never use DMA for SPI, So maybe I am wrong.
For context save/restore implemetation, I think you can read RTOS source code, say FreeRTOS, and ignore queue, semaphore, mutex to see whether you can get there.