ZZomato·Tech KnowledgeL3DSA Round

Virtual Memory and Cache Memory

Problem Explain virtual memory and cache memory - what they are and why they matter.

Be ready to discuss

  • Virtual memory: the abstraction giving each process a large, contiguous, private address space independent of physical RAM layout.
  • Address translation: the MMU walks page tables to map virtual pages to physical frames, with the TLB caching recent translations to avoid a multi-level walk on every access.
  • What it buys you: process isolation (one process cannot touch another's memory), simpler linking and loading, and the ability to over-commit memory beyond installed RAM.
  • Paging and swapping: pages evicted to disk on demand, page faults, and thrashing when the working set exceeds RAM.
  • Demand paging and copy-on-write: why fork() is cheap and why allocation doesn't cost physical memory until first touch.
  • Cache memory: small, fast SRAM in an L1/L2/L3 hierarchy holding recently and frequently used data close to the CPU.
  • Locality of reference: temporal (reuse soon) and spatial (neighbours used soon) - the assumption that makes caching work at all.
  • Cache mechanics: cache lines (typically 64 bytes), associativity, eviction policy, and write-through vs write-back.
  • Why this shows up in application code: cache misses cost hundreds of cycles, so array traversal beats linked-list traversal and row-major beats column-major - and false sharing wrecks multithreaded performance.
  • The unifying idea: the memory hierarchy trades speed against capacity and cost at every level, from registers to disk.
asked …
LeaderboardSalaryAccount