Memory Management Basics and Hierarchy: Address Translation Worked Example
Build the memory hierarchy from CPU registers to storage, then follow a 16-bit logical address through a page table to its exact physical address.
KnowledgeGate Team
Exam prep & CS education

A laptop has registers, caches, RAM, storage, and virtual addresses, but they are not interchangeable names for memory. Confusion starts when a question asks for page bits, an offset, or a physical address. The hierarchy runs from the CPU outward, while the operating system creates mappings and the MMU translates logical addresses into physical addresses. These ideas sit across CS Fundamentals for Exams & Placements, where computer architecture supplies the hardware hierarchy and operating systems supplies address mapping.
What memory management is solving
Memory management connects three actors. A process issues logical, or virtual, addresses. The memory-management unit (MMU) translates each permitted address, while physical memory holds instructions and data.
The operating system creates and manages mappings. Hardware performs each permitted translation using the active mapping data, making translation fast without giving a process unrestricted access to RAM.
It must also track free and occupied memory, allocate and reclaim regions, relocate addresses, enforce protection, allow controlled sharing, and decide what remains resident when RAM is limited. Together, these decisions give every process usable memory without exposing all physical memory.
Processes P1 and P2 may both issue logical address 0x1000. Separate mappings can send the references to different physical locations, while permissions keep either process out of the other's memory. A process address is not automatically a raw RAM address.
The memory hierarchy and why it works
From nearest to farthest from the CPU, the hardware levels are registers, processor caches, main memory, and secondary storage. Closer generally means lower latency, lower capacity, and higher cost per bit. Farther away generally reverses those trends.
The hierarchy works because programs show locality. Temporal locality means recently used data is likely to be reused, as when a loop updates the same counter or array block. Spatial locality means nearby data is likely to be used soon. Reading A[0], A[1], A[2], and A[3] demonstrates it.
Locality keeps a small active working set near the CPU instead of building every byte from the fastest technology. TLB behaviour, multilevel tables, and effective-access-time calculations follow in Memory Hierarchy and Virtual Memory: paging, the TLB, and address translation. Hierarchy-order questions need the four hardware levels and both locality types.
Virtual memory is an address-space abstraction and management mechanism, not another storage chip below secondary storage. Needed parts can be mapped into RAM, while other parts are backed by secondary storage when required.
![Memory-hierarchy pyramid showing CPU registers, processor caches, main memory, and secondary storage, with a locality trace from A[0] through A[3] returning to A[0].](https://cdn.knowledgegate.ai/blog-assets/blog_asset_1784740743725_jvhk1z.jpg)
Logical addresses, physical addresses, pages, and frames
An address space is the set of addresses a process can generate. Paging divides it into equal-sized pages and RAM into equal-sized frames. A page table records each page-to-frame mapping. The offset selects a byte inside the page and remains unchanged during translation.
Under contiguous allocation, a process occupies one continuous physical region, and relocation can use a base address. Under paging, logical pages may occupy non-adjacent frames. Equal size does not make page and frame numbers interchangeable.
A segment is a variable-sized logical unit such as code, data, or a stack, while a page has fixed size. Segmentation bounds, TLB timing, and multilevel page-table structure are treated in Memory management in OS: paging and segmentation explained. A single-level page table is enough to isolate the invariant used in this calculation: translation replaces the page number with a frame number and preserves the offset. Paging removes external fragmentation, but a partly used final page can still create internal fragmentation.
Worked example: translate logical address 13,845
Assume a byte-addressable system with 16-bit logical addresses and 1 KiB pages. Since 1 KiB = 1,024 bytes = 2^10 bytes, the offset needs 10 bits. The page number gets 16 - 10 = 6 bits, giving 2^6 = 64 logical pages.
Translate logical address 13,845. In hexadecimal it is 0x3615. Its 16-bit binary form, split into page and offset fields, is 001101 | 1000010101.
Compute the page number:
floor(13,845 / 1,024) = 13.Compute the offset:
13,845 - (13 x 1,024) = 13,845 - 13,312 = 533.Check the bit fields: binary
001101is decimal 13, and binary1000010101is decimal 533.Read the page table: page 13 has a valid entry that maps to frame 42.
Form the physical address:
(42 x 1,024) + 533 = 43,008 + 533 = 43,541.
The result is decimal 43,541, or hexadecimal 0xAA15. Check it with 43,541 mod 1,024 = 533. If page 13 were absent or lacked permission, hardware would trap to the operating system instead of forming the address.

Traps that turn easy memory questions into wrong answers
Tempting move | Correction | Reason |
|---|---|---|
Treat 1 KiB as 1,000 bytes | Use 1,024 bytes |
|
Use all 16 bits as offset bits | Use 10 offset bits | Page size sets the offset |
Change the offset during translation | Preserve offset 533 | Translation replaces the page field with a frame field |
Treat page 13 and frame 42 alike | Keep their roles separate | Pages are logical; frames are physical |
Read frame 42 as byte address 42 | Start at | A frame number identifies a block |
A cache miss is not automatically a page fault, and virtual memory is not identical to secondary storage. Equal page and frame sizes do not make their numbers equal. Paging can still leave internal fragmentation.
The worked values give a fast check. Page 13 with offset 533 must retain offset 533. Any physical answer whose remainder after division by 1,024 is not 533 is wrong. Page-table-size and effective-memory-access-time numericals use different calculations.
How exams and interviews test basics and hierarchy
Stable question forms ask you to order hierarchy levels, identify each kind of locality, distinguish logical from physical addresses, derive page and offset bits, or translate through a supplied page-table entry.
Try three checks. A[0], A[1], A[2], A[3] shows spatial locality through consecutive locations. A 1 KiB page needs 10 offset bits because 1,024 = 2^10. Page 13 mapped to frame 42 keeps offset 533. Using 1,000 bytes or swapping page and frame produces a wrong result.
Interview follow-ups ask why two processes can safely use the same logical address, why locality makes a hierarchy effective, and what happens after an invalid page-table entry. Strong answers connect mapping, protection, and locality instead of treating them as separate definitions.
The short version and next step
The hierarchy balances latency, capacity, and cost. Locality makes that balance useful by keeping active data nearer the CPU. The operating system manages protected mappings between logical pages and physical frames. The MMU uses those mappings to translate each permitted address.
The decisive result is 13,845 = page 13 + offset 533; page 13 maps to frame 42, so the physical address is 43,541.
Redraw the hierarchy and translation pipeline from memory, then repeat the calculation after changing only the mapping from frame 42 to frame 27. You should obtain (27 x 1,024) + 533 = 27,648 + 533 = 28,181, with offset 533 unchanged.
For a structured route through Operating Systems and the broader CS sequence, continue with the Zero to Hero Complete CS Course.
Keep learning
Memory Hierarchy and Virtual Memory: paging, the TLB, and address translation
Memory hierarchy and virtual memory explained: registers to disk, locality, paging, page tables, the TLB, a worked address translation, and access time.
Segmentation and Hybrid Memory Management in OS: Address Translation with Worked Examples
Learn how pure segmentation and segmented paging translate logical addresses. Follow two complete worked examples, see where faults occur, and avoid common exam traps.
Memory Management Basics and Hierarchy MCQs: 12 Solved Questions with Explanations
Solve 12 published memory-management MCQs with step-by-step explanations covering hierarchy, volatility, locality, MMU translation, address bits, and protection.
Virtual Machine Fundamentals: Hypervisors, VM Types and Worked Address Translation
Build a precise mental model of virtual machines, then apply it to vCPU scheduling, two-stage address translation, virtual I/O and capacity checks.





