OPERATING SYSTEMS/Student Engineering Notebook
Page 12·notes
MAIN MEMORY MANAGEMENT & PAGING—~24 MIN READ·GATE CS LENS

Paging, Multi-Level Page Tables & The TLB

“Translating logical addresses, calculating page table sizes, and computing Effective Memory Access Time (EMAT).”

1.The Fundamental Problem: External Fragmentation

Early operating systems allocated contiguous physical memory blocks to processes. As processes loaded, terminated, and departed, free memory was carved into hundreds of tiny, disconnected holes. Even if total free memory was 20 MB, a new 5 MB process could not load because no single contiguous hole of 5 MB existed. This is External Fragmentation.

To eradicate external fragmentation, modern computer architecture invented Paging.

In paging, physical memory is divided into fixed-size blocks called Frames, and logical (virtual) memory is divided into blocks of the exact same size called Pages (typically 4 KB). Any virtual page can now be placed into ANY available physical frame anywhere in physical RAM.

A virtual address is the address generated by a process; a physical address is the location in RAM. The page table maps the virtual page number (p) to a frame number (f). Each page-table entry (PTE) stores that frame mapping plus control bits such as a valid bit, protection bits, and a dirty bit. The page offset (d) is copied unchanged during translation.

If the PTE says the page is not resident, the hardware raises a page fault. The operating system then loads the page from secondary storage, chooses a free frame or victim page, updates the PTE, and restarts the interrupted instruction. This is demand paging: pages are brought into RAM when referenced rather than loading eagerly.

A TLB (Translation Lookaside Buffer) caches recent page-to-frame translations. A TLB hit avoids a page-table walk; a TLB miss requires consulting the page table in RAM.

2. Virtual address to physical address

[ VIRTUAL ADDRESS ]
        ┌──────────────────────┬──────────────┐
        │ page number (p)      │ offset (d)   │
        └──────────┬───────────┴──────┬───────┘
                   │                  │ copied unchanged
                   ▼                  │
             ┌────────────┐           │
             │   TLB      │           │
             └─────┬──────┘           │
                 hit│ miss            │
                    ▼                 │
             ┌────────────┐           │
             │ Page table │ p → frame│
             └─────┬──────┘           │
                   ▼                  ▼
        ┌──────────────────────┬──────────────┐
        │ frame number (f)     │ offset (d)   │
        └──────────────────────┴──────────────┘
                 [ PHYSICAL ADDRESS ]
The page number is translated through the page table; the offset is preserved.
WORKED NUMERICAL · STUDENT DERIVATION✎ Key Takeaway: Page offset bits NEVER change during translation; only the Page Number (p) is replaced with Frame Number (f) via the Page Table.

3. Address Translation Mechanics in Paging

Problem Statement:
Consider a 32-bit virtual address space with a page size of 4 KB (4096 = 2¹² bytes). Physical RAM is 512 MB (2²⁹ bytes). Calculate the bit breakdown of the logical and physical addresses.
Virtual Address Size32 bits (4 GB virtual memory)Page Size4 KB = 2^12 bytesPhysical RAM Size512 MB = 2^29 bytes
Step 1: Page Offset (d)

Since page size is 4 KB = 2^12 bytes, the offset requires 12 bits in both logical and physical addresses.

Offset bits d = log2(Page Size) = log2(2^12) = 12 bits
Step 2: Page Number (p)

The remaining higher-order bits identify which page of the process is being referenced.

Page bits p = Virtual Address Bits - d = 32 - 12 = 20 bits
↳ Result: The page table contains 2^20 = 1,048,576 entries.
Step 3: Frame Number (f)

In physical memory (512 MB = 2^29 bytes), with 12-bit offset, the frame bits identify the physical frame.

Frame bits f = Physical Address Bits - d = 29 - 12 = 17 bits
Final Answer:Logical Address: 20 bits (Page Number) + 12 bits (Offset). Physical Address: 17 bits (Frame Number) + 12 bits (Offset).
WORKED NUMERICAL · STUDENT DERIVATION✎ Key Takeaway: For multi-level paging with k levels, a TLB miss requires k memory accesses to traverse the page tables + 1 memory access for data: T_miss = t_tlb + (k + 1) * t_m.

4. Effective Memory Access Time (EMAT) with TLB

Problem Statement:
A system has a Translation Lookaside Buffer (TLB) with hit ratio h = 90%. TLB access time is t_tlb = 10 ns, and main memory access time is t_m = 100 ns. Calculate the Effective Memory Access Time (EMAT) for a single-level page table.
TLB Hit Ratio (h)0.90TLB Access Time10 nsMemory Access Time100 ns
Step 1: Case 1: TLB Hit (Probability h)

On a hit, the translation is found in the TLB (10 ns). Then, one main memory access is made to fetch the actual operand/data (100 ns).

T_hit = t_tlb + t_m = 10 + 100 = 110 ns
Step 2: Case 2: TLB Miss (Probability 1 - h)

On a miss, we search TLB (10 ns), then access main memory to read the Page Table Entry (100 ns), then access main memory again to fetch the actual data (100 ns).

T_miss = t_tlb + t_m + t_m = 10 + 100 + 100 = 210 ns
Step 3: Calculate EMAT

Weighted average of hit and miss times.

EMAT = h * T_hit + (1 - h) * T_miss = 0.90 * (110) + 0.10 * (210)
↳ Result: 99 + 21 = 120 ns
Final Answer:EMAT = 120 ns
GATE LENS · EXAM PREPARATION

5. GATE Lens & Exam Practice

Syllabus focus, recurring numerical patterns, common traps, and clearly labelled exam practice. Questions remain source-pending until an official paper and answer key are attached.

EXAM WEIGHTAGE & FOCUS:

Paging address translation, multi-level page table size calculations, and EMAT equations are recurring GATE-style problem patterns. Verify historical frequency against the official paper archive.

recurring exam patterns:
  • •Determining the minimum number of levels required in a hierarchical page table so that each page table fits inside a single frame.
  • •Calculating EMAT with TLBs, multi-level page tables, and page fault rates.
⚠ common student traps:
  • •Don't forget that Page Table Size = (Number of Entries) * (Page Table Entry Size in bytes).
  • •In Multi-Level paging with k levels, each TLB miss requires k + 1 memory accesses, not 2!

Exam Practice / Source Verification Required

1 problem
GATE-style question · 2 MarksTwo-level EMAT = h*(t_tlb + t_m) + (1-h)*(t_tlb + 2*t_m + t_m).

Consider a system with a two-level paging scheme. The TLB search time is 20 ns and main memory access time is 100 ns. The TLB hit ratio is 80%. What is the effective memory access time (in ns)?

A. 140 ns
B. 160 ns
C. 180 ns
D. 220 ns
RAPID REVIEW · NOTEBOOK SUMMARY

6. 1-Minute Panic Revision

core principle:

“Paging eliminates external fragmentation. Virtual Address = Page Number (p) + Offset (d). Physical Address = Frame Number (f) + Offset (d).”

must-remember principles:
  • •Page Offset bits = log2(Page Size).
  • •Number of Page Table Entries = 2^(Virtual Address Bits - Offset Bits).
  • •Page Table Size = (Number of Entries) * (PTE size in bytes).
  • •EMAT = h(t_tlb + t_m) + (1-h)(t_tlb + (k+1)*t_m) for k-level paging.
critical exam pitfalls:
  • •Paging STILL suffers from INTERNAL fragmentation (on the very last frame of a process, avg 1/2 page size).
  • •Offset bits never change between virtual and physical addresses.
decision flow & invariants:
[ VIRTUAL ADDRESS TRANSLATION & TLB PIPELINE ] Virtual Address: [ Page Number (p) | Page Offset (d) ] │ ▼ Lookup in Hardware TLB │ ┌────────────┴────────────┐ ▼ ▼ TLB HIT TLB MISS [ Frame Number (f) [ Walk Page Tables in RAM ] fetched in t_tlb ] [ (k memory accesses) ] │ │ │ Cache (p → f) in TLB │ │ └────────────┬────────────┘ ▼ Physical Address: [ Frame Number (f) | Page Offset (d) ] │ ▼ Access Target Byte in Physical RAM (t_m)
SOURCE TRANSPARENCY & CITATIONS

Primary Academic References & Exam Sources

Every concept in Notes From a B.Tech Brain is synthesized from authoritative academic texts, seminal peer-reviewed research, verified exam archives, and renowned university lectures.

Primary Academic Texts
Operating System Concepts (10th Edition)↗by Silberschatz, Galvin, Gagne · Chapter 9: Main Memory (Section 9.3: Paging & Section 9.3.3: Hardware TLB)

Official slides on page tables, frame allocation, Translation Lookaside Buffer (TLB), and multi-level hierarchy.

ACADEMIC STANDARD
Operating Systems: Three Easy Pieces (OSTEP)↗by Remzi H. Arpaci-Dusseau & Andrea C. Arpaci-Dusseau · Chapter 18: Paging (Introduction, Address Translation & Page Tables)

Free chapter PDF detailing virtual page number (VPN) to physical frame number (PFN) mapping and page table entries.

ACADEMIC STANDARD
Operating Systems: Three Easy Pieces (OSTEP)↗by Remzi H. Arpaci-Dusseau & Andrea C. Arpaci-Dusseau · Chapter 19: Paging: Faster Translations (TLBs)

Full chapter analyzing TLB hit vs miss algorithms, context switch TLB invalidation, and TLB coverage.

ACADEMIC STANDARD
ALTERNATIVE PEDAGOGICAL PERSPECTIVES

If the textbook derivation did not click immediately, consult these targeted video lessons:

What is Paging | Memory Management | Operating SystemGate Smashers (Varun Singla) (16 mins)

First-principles explanation of logical vs physical address spaces, page size = frame size, and why paging eliminates external fragmentation.

Watch Lesson↗
2-Level Paging | Multilevel Paging in Operating SystemGate Smashers (Varun Singla) (15 mins)

Breakdown of how to fit page tables within a frame and calculate total paging levels without memory waste.

Watch Lesson↗
RECOMMENDED YOUTUBE LECTURES & EDUCATORS: MODULE 6: MAIN MEMORY MANAGEMENT & PAGING

Curated lectures on Logical-to-Physical Translation, Page Tables, TLBs, Multi-level Paging & Internal Fragmentation:

Gate Smashers · L-5.9: What is Paging & Address Translation Architecture↗Instructor: Varun Singla · Covers: Logical Address bit-splitting (Page Number p, Offset d), Physical Frames (f, d), MMU hardware

Crystal-clear mental models of base register indexing and physical frame lookup.

Open YouTube↗
Gate Smashers · L-5.13: 2-Level Paging in Operating System | Multilevel Paging↗Instructor: Varun Singla · Covers: Outer page table size, Inner page table, PTE calculations, preventing massive page tables in RAM

Definitive step-by-step formula derivation for multi-level address bit partitioning.

Open YouTube↗
Neso Academy · Translation Lookaside Buffer (TLB) & Effective Memory Access Time↗Instructor: Neso Academy · Covers: TLB Hit Ratio, Associative hardware cache, EMAT = h*(c + m) + (1-h)*(c + 2m) derivations

Blackboard mathematical rigor on single-level and multi-level TLB penalty calculations.

Open YouTube↗
Knowledge Gate · Page Table Size & Inverted Page Table Numericals↗Instructor: Sanchit Jain · Covers: Page table size = (Virtual space / Page size) * PTE, Inverted Page Table hashing, GATE PYQs

Intense numerical drilling on calculating exact memory consumption of hierarchical tables.

Open YouTube↗