%esi, %edi: ???
Processor status register(s): EFLAGS
Currently running: user code / kernel code?
Interrupts: on / off
Virtual memory: on / off
Memory model: small, medium, large, "unreal" (x86-64)
Floating point number registers: (still user register)
Sometimes another “special” set of registers
Some machines don't have floating point
Some processes don't use floating point
Execution environment: status registers and %eip
getpid(): example system call
execute TRAP (in intel, TRAP is called INT, IT IS NOT INTERRUPT)
then as result, some register dump to memory, some load from memory
the process enter kernel mode: more hardware device become visible
Kernel runtime language (CPU don't care which you use):
ML: may not use "stack"
C: must use "stack"

Trap Handler: job is to build kernel runtime environment
switch to correct stack
save registers (EFLAGS, CS/EIP, error code (when faults) of current process) to kernel stack
load registers (new %eip, and status registers) according to table
other stuff
interrupt handler use kernel stack ...
empty stack to original state
invoke IRET (interrupt return), register loaded from kernel stack, back to user mode
Trap: switching request from user code
Interrupt: switching request from hardware
There is a look up table involved for interrupt source storing CPU state - table base pointer established in OS startup - table entry size defined by hardware
Running: currently executing code Block: waiting for device (e.g. disk interrupt), can't run Runable: CPU is not scheduling for this code to run, but it can run

Solution: (1) temporary suspend/mask/defer device interrupt while checking and enqueue (2) lock-free data structure. But don't block all interrupt or for too long time.
Timer:
Behavior
Reason
while True: continue, force process switchTable of Content