Hits and misses
Every memory access needs its virtual page translated to a physical frame. Reading the page tables in RAM each time would be slow, so each core keeps a tiny cache of recent translations: the TLB (translation lookaside buffer).
Process A reads p[0], on virtual page 5. Core 0's TLB already holds page 5 → frame 9, so the translation is one quick lookup. No page table read, and the kernel does nothing at all.
p[ps] is one page further, page 6 (ps is the page size), and core 0's TLB has no entry for it: a miss. On x86-64 the hardware walks the page tables the kernel built, finds frame 3, fills the TLB and retries the load.
Flushes and shootdowns
munmap asks the kernel to remove page 6. The kernel clears page 6's entry in A's page table. But a TLB is a copy: core 0 still holds 6 → 3, a stale entry that would let A keep using frame 3.
So the kernel must flush the stale entry itself. It runs a privileged instruction for that one page: invlpg on x86-64, sfence.vma on RISC-V. Page 5's entry survives, so A keeps its fast hits.
Process A has a second thread running on core 1, and it used page 6 earlier. Core 1's TLB still holds 6 → 3. Core 0 cannot reach into another core's TLB: each core can only flush its own.
So the kernel on core 0 sends an inter-processor interrupt (IPI) to core 1. Core 1 stops what it was doing, runs the kernel's flush handler, removes its 6 → 3 entry and reports back.
Core 0 waits until every core that may hold the page has answered. Only then is frame 3 safe to give to another process, and munmap returns 0. A later touch of page 6 now faults.
Switching processes
Now the kernel switches core 0 to process B. B's page 5 is frame 12, not 9. Without tags, A's old entries would translate B's addresses wrongly, so the TLB is flushed, and B starts with misses.
With address-space IDs (ASIDs; x86-64 calls them PCIDs), each entry carries its process's tag. The switch just sets B's tag in a register. A's 5 → 9 and B's 5 → 12 sit side by side; only matching tags hit.
The TLB makes translation fast, but it is a copy the hardware never updates. So whenever the kernel removes or changes a mapping, it flushes: one entry locally, other cores by shootdown, and on a switch either everything or, with ASIDs, nothing.
What happens
;; step 1/11 · tlb one TLB per core, inside the CPU entry virtual page -> physical frame (+ valid, protection) size small: a typical TLB has 32, 64 or 128 entries page 4096 bytes on x86-64, so page = address >> 12 process A (example numbers): page 5 -> frame 9 page 6 -> frame 3 core 0 TLB 5→9 (A used page 5 earlier) core 1 TLB 6→3 (A's second thread used page 6)
The page and frame numbers are made up to keep them short: real mmap addresses are much higher (around 0x7f... on x86-64 Linux), and real TLBs have dozens of entries, not three. x86-64 refills the TLB in hardware by walking the page tables, and so do most RISC-V chips (the RISC-V spec also allows a software refill). Older RISC designs such as MIPS use a software-managed TLB: a miss traps to the kernel, which fills the entry itself and returns to retry the same instruction.