KERNELA page 59A page 63B page 5121x = p[0];2y = p[ps];3r = munmap(p + ps, ps);CORE 0ASID 1STALEASID 2STALEASID 2STALEBCORE 1ASID 1STALEASID 2STALEASID 2STALE56312
Back: the kernel and the page tables in RAMFront: process A's code, process B, two cores and their TLBsTokens: page numbers, a page-table walk, flushes, an IPI and its answerAt the back: the kernel and the page tables in RAM. In front: process A's code, process B, and two cores, each with its own TLB of three entries (page → frame). Line 1 hits in core 0's TLB; line 2 misses and the hardware fetches frame 3 from the page tables. munmap clears page 6, leaving stale copies; the kernel flushes core 0's and shoots down core 1's with an interrupt. A switch to B flushes everything, unless ASID tags keep A's and B's entries apart. 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.

Hits and misses

  1. 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).

Flushes and shootdowns

Switching processes

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.