I'm currently reading How Linux Works: What Every Superuser Should Know, and I read the following about context switching:
- The CPU (the actual hardware) interrupts the current process based on an internal tinier, switches into kernel mode, and hands control back to the kernel.
- The kernel records the current state of the CPU and memory, which will be essential to resuming the process that was just interrupted.
- The kernel performs any tasks that might have come up during the preceding time slice (such as collecting data from input and output, or I/O, operations).
- The kernel is now ready to let another process run. The kernel analyzes the list of processes that are ready to run and chooses one.
- The kernel prepares the memory for this new process, and then prepares the CPU.
- The kernel tells the CPU how long the time slice for the new process will last.
- The kernel switches the CPU into user mode and hands control of the CPU to the process.
I understand what needs to be saved from the CPU's state (register values, etc...), but I don't understand what memory needs to be managed. Doesn't the process have its own block of memory, which should be unaffected by the context switch?
What about memory does the kernel need to save between context switches?