What is the Memory Hierarchy, and why does the operating system rely on virtual memory and page replacement?
The memory hierarchy organizes storage into tiers balancing latency, capacity, and cost: CPU registers/caches (0.5–10 ns, MBs), DRAM main memory (50–100 ns, GBs), and secondary SSD/HDD storage (10 µs–10 ms, TBs). Because DRAM is too small to hold all concurrent application data, the operating system virtualizes memory into 4KB pages. When a process accesses a page not resident in DRAM, a page fault occurs, requiring the OS to fetch the page from disk and evict an existing resident page if physical memory is full. Page replacement algorithms decide which frame to evict, minimizing disk I/O to prevent system thrashing.