CPU is one of the most important resources in a computer.
Scheduling/policy in CPU decides which code to run next.
The mechanism in CPU is Context Swap.
Execution context in CPU is a set of information that needs to be preserved to maintain the illusion that a piece of code is always running on the CPU.
General registers in CPU range from 8 to 128, depending on the architecture.
In Context Swap, the running context from the CPU is saved into memory.
SP (Stack Pointer) is a register in the CPU.
IP (Instruction Pointer) is a register in the CPU.
Config register is a register in the CPU.
Context Swap is the process of switching between contexts.
SR (Status register) is a register in the CPU.
Everything else on main mem, stack, etc. is not a register in the CPU.
The scheduler then picks the next context.
GP (General Purpose) is a register in the CPU.
Process: Massive container used to account for all kinds of resources, with one execution context and kernel swaps between processes.
Thread: Single execution context and stack within a process, with the process able to have more than one thread.
Kernel-level thread: Managed, scheduled, and swapped by the kernel.
User-level thread: Opaque to the kernel and managed by code running within the process itself.
Process switching is slow.
Threads in the same address space can communicate directly with memory.
Threads in the same address space can use special synchronization primitives provided by the architecture.