OS schedules processes to share CPU.
Process State Transitions
Context Switching
When a process is running, its program counter, register values, stack pointer, etc. are contained in the hardware registers of the CPU. The process has direct control of the CPU hardware for now.
When a process is not the one currently running, its current register values are saved in a process descriptor data structure (PCB - process control block)
Context switching involves moving state between CPU and various processes' PCBs by the OS.