optional · CSS study notes
Memory Hierarchy
CSS Optional — Paper-II, Section-A · Chapter 7 · 🔥 High-yield conceptual + numerical topic
No single memory technology is simultaneously fast, large, and cheap. SRAM is fast but costs roughly 100× more per bit than DRAM; disk is cheap and vast but a million times slower. The memory hierarchy is the engineering answer to this trilemma: layer several technologies so the system behaves as though it has the speed of the fastest and the capacity of the largest.
SECTION 1 — The Hierarchy Structure
▲ Faster, smaller, costlier per bit
│
┌────┴─────────────┐
│ Registers │ ~0.3 ns | ~256 bytes | inside CPU
├──────────────────┤
│ L1 Cache │ ~1 ns | 32–64 KB | SRAM, split I/D
├──────────────────┤
│ L2 Cache │ ~4 ns | 256 KB–1 MB | SRAM, per core
├──────────────────┤
│ L3 Cache │ ~15 ns | 8–32 MB | SRAM, shared
├──────────────────┤
│ Main Memory │ ~60–100 ns| 8–64 GB | DRAM
├──────────────────┤
│ SSD / Flash │ ~0.1 ms | 256 GB–4 TB | NAND flash
├──────────────────┤
│ Hard Disk │ ~10 ms | 1–20 TB | magnetic
├──────────────────┤
│ Tape / Cloud │ seconds | unlimited | archival
└──────────────────┘
│
▼ Slower, larger, cheaper per bit
1.1 The Four Properties That Change Down the Hierarchy
As you descend:
| Property | Direction | Reason |
|---|---|---|
| Access time | Increases | Cheaper, denser technology is slower |
| Capacity | Increases | Lower cost per bit permits more of it |
| Cost per bit | Decreases | Simpler storage elements per bit |
| Frequency of access by CPU | Decreases | Locality keeps most traffic at the top |
That last row is the one candidates forget, and it is the row that makes the whole scheme work: the CPU touches the top levels overwhelmingly more often than the bottom ones.
1.2 Managed By Whom?
A distinction examiners like:
| Level | Managed by |
|---|---|
| Registers | Compiler (register allocation) |
| Cache | Hardware (cache controller) |
| Main memory | Operating System (virtual memory manager) |
| Disk / files | Operating System + user |
This is why cache is invisible to the programmer while virtual memory is an OS service.
SECTION 2 — Why the Hierarchy Works: Locality of Reference
The hierarchy would fail completely if memory access were random — a small fast level would then be hit only in proportion to its size. It succeeds because programs exhibit locality:
- Temporal locality — a location referenced now will likely be referenced again soon. Cause: loops, recursion, repeatedly used variables and subroutines. Exploited by: keeping recently used data in the upper levels.
- Spatial locality — locations near a referenced one will likely be referenced soon. Cause: sequential instruction execution, array traversal, contiguous data structures. Exploited by: transferring whole blocks rather than single words.
- Sequential locality — a special case of spatial locality: instructions execute in increasing address order unless a branch occurs. Exploited by: instruction prefetching.
The 90/10 rule of thumb: a program typically spends about 90% of its execution time in about 10% of its code. That 10% fits comfortably in cache, which is why small caches produce large gains.
2.1 Two Governing Principles
- Inclusion property — data present at level i is also present at level i+1. Registers ⊂ L1 ⊂ L2 ⊂ Main memory ⊂ Disk. This simplifies coherence, though some designs use exclusive caches to avoid duplication.
- Coherence property — copies of the same data at different levels must be kept consistent. Enforced by write-through or write-back policies (see Cache Memory) and, in multiprocessors, by protocols such as MESI.
SECTION 3 — Levels in Detail
3.1 Registers
Fastest storage, physically inside the CPU datapath, accessible in a single cycle with no addressing overhead. Typically 16–32 general-purpose registers of 32 or 64 bits. Allocated by the compiler, which is why register pressure is a compiler-optimisation concern.
3.2 Cache (L1 / L2 / L3)
SRAM buffers bridging the CPU–DRAM speed gap.
- L1 — smallest and fastest, split into separate instruction and data caches (a Modified Harvard arrangement — see Harvard and Non-Neumann Architecture). Private to each core.
- L2 — larger, unified, usually private per core.
- L3 — largest, shared across all cores, which also makes it the medium for inter-core data sharing.
Fully covered in Cache Memory.
3.3 Main Memory (DRAM)
The working store holding running programs and their data. Volatile. Slower than cache but far denser and cheaper. See Memory Organization for SRAM vs DRAM and chip interfacing.
3.4 Virtual Memory ⭐
Virtual memory extends the hierarchy onto disk, letting a program use more address space than the machine has physical RAM.
- Paging — virtual address space is divided into fixed-size pages (commonly 4 KB); physical memory into equally sized frames. A page table maps pages to frames.
- Page fault — the referenced page is not in physical memory; the OS fetches it from disk. Extremely expensive (milliseconds versus nanoseconds), so page-fault rates must be kept minuscule.
- TLB (Translation Lookaside Buffer) — a small fully associative cache of recent page-table entries. Without it, every memory reference would require an extra memory access just to read the page table.
- Thrashing — when the working set exceeds available frames, the system spends more time paging than computing. Throughput collapses.
Cache vs Virtual Memory — a favourite comparison
| Feature | Cache | Virtual Memory |
|---|---|---|
| Levels involved | CPU ↔ Main memory | Main memory ↔ Disk |
| Block unit | Cache line (16–64 B) | Page (4 KB typical) |
| Managed by | Hardware | Operating System |
| Miss called | Cache miss | Page fault |
| Miss penalty | ~10–100 cycles | ~millions of cycles (ms) |
| Purpose | Speed | Capacity + protection + isolation |
| Visible to programmer | No | Indirectly (address space) |
The key insight: cache and virtual memory apply the same hierarchy principle at different scales — but because the disk penalty is roughly 100,000× the DRAM penalty, virtual memory must use full associativity and sophisticated replacement, whereas cache can afford simpler schemes.
3.5 Secondary and Tertiary Storage
SSDs and hard disks provide non-volatile bulk storage; tape and cloud archives form the tertiary level. See External Memory.
SECTION 4 — Formulas (Derived, Explained, Extended to More Levels)
One idea builds every formula on this page:
🗣️ In simple words: list every possible case (hit here, miss here and hit there, …), write how often it happens and how long it takes, multiply, and add. If you forget a formula in the exam hall, rebuild it this way.
4.1 Building Blocks — Hit Ratio and Miss Ratio
What it finds: how often the faster level already has the data.
- Local hit ratio — out of the accesses that reach a level, the fraction found there. Exam values for L2, L3 … are local unless stated.
- Global hit ratio — out of all CPU accesses, the fraction served by that level.
🗣️ In simple words: if L1 hits 80% and L2 hits 90% of what reaches it, L2 actually serves only 20% × 90% = 18% of all accesses.
4.2 Two Levels — Simultaneous vs Hierarchical
4.2.1 The Difference First
| Point | Simultaneous (Parallel / Look-aside) | Hierarchical (Serial / Look-through) |
|---|---|---|
| How memory is searched | Cache and memory searched at the same time | Memory searched only after the cache says "miss" |
| Time on a hit | ||
| Time on a miss | only | (wasted cache lookup + memory) |
| Formula | ||
| Short form | ||
| Answer (same data) | Slightly smaller | Larger by exactly |
| Keywords in question | "simultaneous", "parallel", "look-aside" | "hierarchical", "sequential", "look-through", "miss penalty" |
If the question names neither, write your assumption in one line before solving.
4.2.2 Simultaneous Access — Derivation
What it finds: average time per access when cache and memory start searching together.
Step 1: List the cases
- Hit → probability , time
- Miss → probability , time (memory was already searching, so no extra cache time)
Step 2: Probability × time, then add
Step 3: Simplify
🗣️ In simple words: start from slow memory time, and every hit saves you .
4.2.3 Hierarchical Access — Derivation
What it finds: average time per access when memory is checked only after a cache miss.
Step 1: List the cases
- Hit → probability , time
- Miss → probability , time
Step 2: Probability × time, then add
Step 3: Simplify
🗣️ In simple words: everyone pays the cache time; only the misses also pay memory time.
This is the textbook AMAT formula:
4.2.4 Gap Between the Two Models
🗣️ In simple words: the difference is just the cache time wasted on misses. (Numericals 1 and 2: ns.)
4.3 Three Levels — Derivation
- = local hit ratios of L1 and L2; main memory always has the data, so
- = access times of L1, L2, memory
4.3.1 Hierarchical (Three Levels)
Step 1: List the cases
| Case | Probability | Time paid |
|---|---|---|
| Hit in L1 | ||
| Miss L1, hit L2 | ||
| Miss L1 and L2, found in memory |
Step 2: Expanded form
Step 3: Collect each time term
- appears in all three cases → coefficient
- appears in cases 2 and 3 → coefficient
- appears only in case 3 → coefficient
Step 4: Simplified form
Step 5: Nested form (exam method — innermost bracket first)
🗣️ In simple words: each level's time is multiplied by the fraction of accesses that get down to that level. Check with Numerical 3: ns.
4.3.2 Simultaneous (Three Levels)
Each case pays only the time of the level where the data is found:
| Case | Probability | Time paid |
|---|---|---|
| Found in L1 | ||
| Found in L2 | ||
| Found in memory |
Same data as Numerical 3:
(versus 6 ns hierarchical)
4.4 General Formula for n Levels ⭐
Step 1: Probability of reaching level i (missed every level above it)
Step 2: Hierarchical, n levels (each level's time × chance of reaching it)
Step 3: Simultaneous, n levels (each level's time × chance the data is found exactly there, with )
Step 4: Nested hierarchical form (fastest by hand)
Four levels written out (Registers, L1, L2, memory):
Check with Numerical 4: ns.
4.5 Reverse Formulas — Finding the Hit Ratio
What it finds: the hit ratio needed to reach a target .
Simultaneous — from :
Hierarchical — from :
Check with Numerical 5 (simultaneous): .
4.6 Virtual Memory Formulas
4.6.1 TLB, No Page Fault — Derivation
What it finds: average time to get one data word when addresses must be translated.
Step 1: List the cases
- TLB hit → probability , time (translation found, then read data)
- TLB miss → probability , time (read page table from memory, then read data)
Step 2: Probability × time
Step 3: Simplify
Without any TLB: every access reads the page table first.
🗣️ In simple words: everyone pays TLB + data access; only TLB misses pay one extra memory trip. Check with Numerical 6: ns.
4.6.2 More Levels — k-Level Page Table
A TLB miss now walks tables, one memory access per level:
- gives back the formula in 4.6.1.
- Example (Numerical 6 data, 2-level table): ns.
- Without a TLB: .
4.6.3 Page Faults — Derivation
Step 1: List the cases
- No fault → probability , time
- Fault → probability , time (disk read + restart)
Step 2: Probability × time
Step 3: Reverse — maximum allowed fault rate
Check with Numerical 8: .
Dirty-page variant ( = fraction of victim pages that were modified and must be written back):
TLB + page fault together (simple combined model):
4.7 Paging Size Formulas
What they find: how a virtual address is split and how big the page table is.
- Offset bits — must name every byte inside one page:
- Page number bits and number of pages:
- Frames and frame number bits:
- Page table (one entry per page):
- More levels — multi-level page table:
Example: 32-bit VA, 4 KB pages, 4-byte entries → , entries per table page , levels .
4.8 Cost and Performance Formulas
Average cost per bit (weighted average — the big cheap level dominates):
- = cost per bit (or per MB) at level , = size of level
Speedup (how many times faster the hierarchy is than the slow level alone):
Percentage time saved:
Access efficiency (how close the system is to pure cache speed; ideal = 1):
Example (Numerical 1): .
4.9 One-Look Formula Sheet
| Formula | What it finds | Use when |
|---|---|---|
| Average access time, 2 levels | Simultaneous / parallel | |
| Average access time (AMAT), 2 levels | Hierarchical / serial | |
| Average access time, 3 levels | Hierarchical | |
| Average access time, 3 levels | Simultaneous | |
| , | Average access time, n levels | Hierarchical, any depth |
| Required hit ratio | Reverse, simultaneous | |
| EAT with TLB | Paging, 1-level table | |
| EAT with TLB | k-level page table | |
| EAT with page faults | Fault rate given | |
| Maximum fault rate | Reverse page-fault problem | |
| Page table size | Paging sizes | |
| Average cost per bit | Cost of hierarchy |
4.10 Easy Ways to Remember the Formulas 🧠
4.10.1 The Master Key — "Chance × Time, Add Them Up"
- Analogy: your daily trip to the office. 80% of days the road is clear (20 min), 20% of days there is traffic (60 min). Average = 0.8 × 20 + 0.2 × 60 = 28 min. Every memory formula works the same way.
- Exam routine (30 seconds): draw a small table with Case | Chance | Time, multiply across, add down. If you forget a formula, this rebuilds it.
4.10.2 Simultaneous vs Hierarchical — The Book Search
- Hierarchical = check the shelf first, then go to the library. If the book is not on the shelf, you have wasted shelf-checking time and still pay the library trip → miss costs .
- Simultaneous = send your brother to the library while you check the shelf. If the shelf fails, the library answer is already on its way → miss costs only .
- Memory hook: "Hierarchical = Har baar cache" — every access pays the cache time. "Simultaneous = Skip" — a miss skips the cache time.
- Sanity check: hierarchical answer is always bigger than simultaneous by — the wasted shelf checks.
4.10.3 The Short Form — "Sab ka T₁, Missers ka T₂"
- Everyone pays (all accesses check the cache).
- Only the missers pay (only go down to memory).
- Same sentence as AMAT: Hit time + Miss rate × Miss penalty.
- Simultaneous short form → "start slow, every hit gives a discount of " — like a shop price minus a discount on each lucky day.
4.10.4 Multi-Level — The Staircase / Waterfall
- Analogy: searching for your keys — first your pocket, then your room, then the whole house. Everyone searches the pocket; only those who fail go to the room; only those who fail again search the house.
- Rule: each level's time × the people who reached that level.
- Hook: "Keep multiplying the misses." The chance to reach the next floor is the previous misses multiplied together:
- Write those multipliers in front of and add — that is the n-level hierarchical formula.
- Simultaneous version: same multipliers, but also multiply by that level's own (data is found there), and the last level has .
- Nested form hook: "Open the innermost bracket first" — like peeling an onion from the inside out.
4.10.5 TLB — The Phone Diary
- Analogy: TLB = your small pocket diary of phone numbers; page table = the big phone directory kept at home (in memory).
- Number in the pocket diary (TLB hit) → just make the call → 1 memory trip.
- Not in the diary (TLB miss) → go home, look in the directory, then call → 2 memory trips.
- Hook: "Miss = one extra trip." Hence the short form "two minus H":
At most 2 trips; your hits cut part of the second trip.
- k-level page table = a directory spread over k cupboards → a miss costs k extra trips → .
- No TLB at all → always go home first → (or ).
4.10.6 Page Fault — "Small p, Giant Penalty"
- Analogy: a bus that is on time 999 days out of 1,000, but on the 1,000th day it breaks down and you wait a whole week. Your average trip time is ruined by that one day.
- A page fault is ~100,000× slower than memory, so even makes the system ~100× slower.
- Hook: in , tiny p × huge penalty still dominates — that is why p must be about 1 in a million.
4.10.7 Reverse Formulas — "Gap Covered ÷ Total Gap"
- Analogy: a road from slow () to fast (). The hit ratio is how far along the road your target has come: distance covered ÷ full distance.
- Same logic for the page fault rate: — allowed extra time ÷ extra cost of one fault.
4.10.8 Paging Bits — The House Address
- Analogy: a virtual address = street number (page number) + house number on that street (offset).
- Offset = (page size) — you need enough house numbers for every byte in one page. Rest of the bits = page number.
- Hook: "Street changes, house number stays." Translation changes only the page number into a frame number; the offset is copied as it is.
- Page table size = Pages × Entry size — like a class register: number of students × space per line.
- Powers of 2 to know by heart: = 1 K, = 1 M, = 1 G → 4 KB = , 8 KB = .
4.10.9 Cost — The Doodh Patti Mix
- Analogy: mix 1 cup of expensive cream with 1,000 cups of ordinary milk — the cost per cup of the mixture is almost the cost of ordinary milk. The big cheap level dominates the average.
- That is the whole hierarchy: cost close to DRAM, speed close to cache.
4.10.10 Speedup — "Old ÷ New"
- Speedup = old time ÷ new time (bigger number on top, answer above 1).
- % saved = (old − new) ÷ old × 100.
- Efficiency = — "how close you are to pure cache speed"; 1 means perfect.
4.10.11 Quick Answer Checks in the Exam ✅
- must lie between the fastest and slowest level — if it doesn't, recheck.
- Hierarchical answer > simultaneous answer for the same data.
- All case chances must add up to 1.
- Convert ms / µs to ns before substituting (1 ms = ns, 1 µs = ns).
4.10.12 Memory Hooks at a Glance
| Formula | Hook | Picture |
|---|---|---|
| Any average time | Chance × Time, add them up | Daily office trip |
| Sab ka T₁, missers ka T₂ | Shelf first, then library | |
| Start slow, discount per hit | Brother goes to library at the same time | |
| n levels | Keep multiplying the misses | Pocket → room → house |
| Two minus H; miss = one extra trip | Pocket diary vs home directory | |
| k cupboards = k extra trips | Directory spread over cupboards | |
| Small p, giant penalty | Bus breaks down once, you wait a week | |
| Reverse H or p | Gap covered ÷ total gap | Road from slow to fast |
| Offset bits | Street changes, house number stays | House address |
| Big cheap level dominates | Cream + milk mix | |
| Speedup | Old ÷ New | Before vs after |
SECTION 5 — Solved Numericals
🧮 Numerical 1 — Two-Level Effective Access Time
Q: Cache access time = 10 ns, main memory access time = 100 ns, hit ratio = 0.9. Find the effective access time under simultaneous access.
Step 1: Given
Step 2: Formula (simultaneous access)
Step 3: Substitute and solve
Step 4: Speedup over memory alone
Answer: 19 ns.
Interpretation: memory alone would cost 100 ns per access; the hierarchy delivers 19 ns — a 5.26× speedup from a cache far smaller than main memory.
🧮 Numerical 2 — Hierarchical Access (the miss pays both levels)
Q: Same values as Numerical 1, but memory is consulted only after the cache lookup fails.
Step 1: Given (same values as Numerical 1)
Step 2: Formula (hierarchical access, a miss pays the cache lookup and then memory)
Step 3: Substitute and solve
Answer: 20 ns — 1 ns more than Numerical 1, exactly the wasted cache lookup on the 10% of accesses that miss.
⚠️ Read the question carefully to identify which access model applies. This pair is a deliberate examiner trap.
🧮 Numerical 3 — Three-Level Hierarchy ⭐
Q: A system has L1 cache (2 ns, hit ratio 0.80), L2 cache (10 ns, hit ratio 0.90 for accesses reaching it), and main memory (100 ns). Find the effective access time under hierarchical access.
Step 1: Given
Step 2: Resolve the innermost level first (L2 together with memory below it)
Step 3: Combine with L1
Answer: 6 ns.
Access distribution worth stating:
Only 2% of accesses ever touch DRAM — that is the entire value proposition of a multi-level hierarchy.
🧮 Numerical 4 — Four-Level Hierarchy Including Registers
Q: Registers 0.5 ns (hit 0.5), L1 2 ns (hit 0.9), L2 10 ns (hit 0.95), memory 80 ns. Find effective access time, hierarchical.
Step 1: Given
Step 2: L2 subsystem (innermost)
Step 3: L1 subsystem
Step 4: Register level (outermost)
Step 5: Improvement over raw memory
Answer: 2.2 ns — against 80 ns for raw memory, a 36× improvement. Note the method: always resolve the innermost level first and work outward.
🧮 Numerical 5 — Required Hit Ratio (reverse problem)
Q: Cache = 8 ns, main memory = 120 ns. What hit ratio achieves an effective access time of 20 ns?
Step 1: Set up the weighted-average equation
Step 2: Expand and collect the H terms
Step 3: Solve for H
Answer: 89.29% hit ratio required.
The method for every reverse problem is identical: write the weighted-average equation, expand, and solve for the unknown.
🧮 Numerical 6 — Virtual Memory with TLB ⭐
Q: TLB access time = 1 ns, main memory access time = 50 ns, TLB hit ratio = 90%. Assume no page faults. Find the effective memory access time.
Step 1: Given
Step 2: Case A, TLB hit (search TLB, get the frame number, access memory)
Step 3: Case B, TLB miss (search TLB and fail, read the page table from memory, then access the data)
Step 4: Weighted average
Answer: 56 ns.
The point: a TLB miss costs an extra full memory access because the page table itself lives in memory. Without any TLB, every reference would cost 100 ns — the TLB alone saves 44%.
🧮 Numerical 7 — Page Fault Impact ⭐
Q: Memory access time = 100 ns. A page fault takes 10 ms to service. If the page fault rate is 0.001 (1 in 1,000), find the effective access time and the slowdown.
Step 1: Given, with units converted to ns
Step 2: Effective access time
Step 3: Slowdown
Answer: ≈10.1 μs, a 101× slowdown.
Interpretation: a page fault rate of just 0.1% makes the system 101 times slower. This is why acceptable page fault rates are on the order of 1 in 10⁶ or lower, and why thrashing is catastrophic rather than merely inconvenient.
🧮 Numerical 8 — Acceptable Page Fault Rate (reverse)
Q: Using the values above, what page fault rate keeps the effective access time within 10% of the ideal 100 ns (i.e. at most 110 ns)?
Step 1: Set up the equation (EAT must not exceed 110 ns)
Step 2: Expand and collect the p terms
Step 3: Solve for p
Answer: roughly one fault per million accesses. This calculation is the standard way of demonstrating just how rare page faults must be, and it is a frequently set exam problem.
🧮 Numerical 9 — Page Table Sizing
Q: A system has a 32-bit virtual address space, 4 KB pages, and 4-byte page table entries. Find the number of pages and the page table size.
Step 1: Virtual address space and page size
Step 2: Number of pages
Step 3: Page table size
Answer: 1,048,576 pages; page table = 4 MB per process.
Follow-up worth adding: 4 MB per process is unacceptable when hundreds of processes run, which is precisely why real systems use multi-level page tables or inverted page tables rather than one flat table.
🧮 Numerical 10 — Address Splitting for Paging
Q: A 32-bit virtual address with 8 KB pages. How many bits are the page number and the offset? How many frames exist in 512 MB of physical memory?
Step 1: Offset bits (page size bytes)
Step 2: Page number bits
Step 3: Number of physical frames
Step 4: Frame number bits
Answer: page number 19 bits, offset 13 bits; 65,536 frames requiring 16 frame-number bits.
Note the offset is the same width in both virtual and physical addresses — only the page/frame number is translated. This is a commonly tested fact.
🧮 Numerical 11 — Average Cost per Bit of a Hierarchy
Q: A system has 1 MB of cache costing Rs 500 per MB and 1,000 MB of DRAM costing Rs 2 per MB. Find the average cost per MB of the combined memory system.
Step 1: Total cost
Step 2: Total capacity
Step 3: Average cost per MB
Answer: Rs 2.50 per MB.
The whole hierarchy argument in one number: the system costs almost as little per MB as pure DRAM (Rs 2) while performing close to cache speed. Achieving 1,001 MB of pure cache would have cost Rs 500,500 — 200× more.
🧮 Numerical 12 — Speedup Delivered by the Hierarchy
Q: Without any cache, every access costs 90 ns. With a two-level cache the effective access time is 6 ns. Find the speedup and the percentage of time saved.
Step 1: Speedup
Step 2: Percentage of time saved
Answer: 15× speedup; 93.3% of memory access time eliminated.
SECTION 6 — Exam Guidance
🎯 CSS Exam Angle
The memory hierarchy is examined in three ways:
- The diagram question — draw the pyramid with speed, size, and cost annotated at each level. Quick, reliable marks. Always label the three trends (speed ↓, capacity ↑, cost/bit ↓ as you descend) and add the fourth that most candidates omit: frequency of access decreases.
- The justification question — "why does a memory hierarchy work?" The answer is locality of reference, and a strong response names temporal, spatial, and sequential locality with a concrete cause for each (loops, arrays, sequential execution).
- The numerical — effective access time across two, three, or four levels, or a virtual-memory/TLB/page-fault calculation.
Method for every multi-level numerical: resolve the innermost level first, then work outward. Attempting to compute all levels simultaneously is where candidates go wrong.
Always state the access model (simultaneous or hierarchical) you are assuming before substituting — if the question is ambiguous, say which you assume and why. Examiners reward that explicitly.
🔁 Repeated CSS Questions
- Draw and explain the memory hierarchy, showing the speed–capacity–cost trade-off. (Very frequently repeated)
- Why does the memory hierarchy work? Explain locality of reference with examples. (Frequently repeated)
- Calculate the effective access time for a two-level or three-level memory hierarchy. (Numerical — frequently repeated)
- Differentiate between cache memory and virtual memory. (Frequently repeated)
- What is a TLB? Calculate effective access time with and without a TLB. (Numerical)
- What is a page fault? Show numerically why the page fault rate must be extremely low. (Numerical)
- Explain thrashing and its effect on system performance.
- Calculate page table size given the virtual address space, page size, and entry size. (Numerical)
- Explain the inclusion and coherence properties of a memory hierarchy.
- Which levels of the hierarchy are managed by hardware, the compiler, and the operating system?
⚠️ MCQ Traps
- Cost per bit decreases as you go down the hierarchy, while total cost of that level may rise — the two are different quantities. Cost per bit is what falls.
- Cache is managed by hardware; virtual memory is managed by the operating system. This is the cleanest distinguishing fact between them.
- A cache miss costs tens of cycles; a page fault costs milliseconds — a difference of roughly five orders of magnitude, not a matter of degree.
- A TLB miss costs one extra memory access, not a page fault. TLB miss and page fault are different events: a TLB miss means the translation is absent; a page fault means the page is absent.
- The page offset is not translated — it is identical in the virtual and physical address. Only the page number becomes a frame number.
- Registers are managed by the compiler, not by hardware or the OS.
- Locality is a property of programs, not of hardware. The hierarchy exploits locality; it does not create it. A program with genuinely random access patterns defeats the hierarchy entirely.
- Increasing cache size does not always reduce misses proportionally — compulsory misses are unaffected by size, and gains flatten once the working set fits.
- The hierarchy provides the illusion of a large fast memory, not an actual one — the phrasing examiners look for.