Back to the 2014 paper

Module 4: Memory Organization

20147m

Explain virtual memory. Explain the role of logical as well as physical address.

Worked SolutionAI Assisted

Virtual Memory

Definition: Virtual memory is a memory management technique that makes an application think it has contiguous, large private address space, independent of physical RAM size, by automatically moving data between RAM and disk (swap/backing store) via paging/segmentation. It gives illusion of virtual size >> physical size.

OS + MMU provide address translation per reference; only active working set stays in RAM, rest on disk, loaded on demand (page fault).

Why Virtual Memory?

  • Run programs larger than physical memory.
  • Multiprogramming isolation & protection (each process virtual space).
  • Simplified linking/loading, no external fragmentation (with paging).

Logical (Virtual) vs Physical Address - Roles

Logical / Virtual Address - Generated by CPU before translation.

  • Address seen by process/compiler: e.g. 3232-bit virtual → 4GB4GB per process (2322^{32}), 4848-bit in x86-64.
  • Partitioned: | Virtual Page Number (VPN) | Offset | (offset = page size bits; e.g. 4KB4KB page → 1212 bits offset).
  • Never used to access RAM directly; goes through MMU.
  • Contiguous from process view; sparse vs file mapping allowed.
  • Protect bits checked per virtual page.

Physical Address - Actual address on RAM bus after translation.

  • After MMU/TLB lookup: | Physical Frame Number (PFN) | Offset |.
  • Range limited by installed RAM: e.g. 1GB1GB RAM → 3030-bit physical.
  • Used by cache/memory controller.
  • Multiple virtual pages (even from different processes) can map to same physical frame (shared memory) or one virtual page can map nowhere (paged out → page fault).

Translation flow:

CPU issues VA ──► TLB (VPN→PFN) hit? ──► PA to cache/RAM
                  │ miss
                  └─► Page Table walk (in RAM) ──► PFN + valid bit
                               │ invalid (not resident)
                               └─► Page Fault → OS loads frame from disk, updates table, retries

Example: VA 0x00403F12 (VPN=0x403,offset=0xF12VPN=0x403, offset=0xF12) with 4KB4KB pages, page table maps VPN 0x403→PFN 0x1A2VPN\ 0x403 → PFN\ 0x1A2 → PA 0x1A2F12.

Key distinction: Logical addresses give program portability & protection; physical addresses give actual storage location. Compiler/linker deals in logical; MMU/OS manages physical. Without translation, process would see raw RAM limits and fragmentation.

Modern extensions: Demand paging, copy-on-write, memory-mapped files, TLB, multi-level page tables all build on this split.

Similar questions

Budget AppAndroid App

Pocketly on Android

Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.