Process switching steps
- mode(user) switching for each case - save process state only
- process switching - save context PCB(control block) → to appropriate queue
- Decide whether to do a context switch, and whether a context switch is permissible now.
- Save all of prev’s user-mode register values (EIP, ESP, …) on prev’s kernel stack.
- Find the best process to schedule for execution using the process scheduling algorithm.
- Switch from the address space of prev to the address space of next
- Switching the Page Global Directory to install a new address space
- Switch from the kernel stack of prev to the kernel stack of next
- Switch from the hardware context of prev to the hardware context of next.
- update state of process → update mm structure

prev process 1 to next process 2 process switching