Why can adding an SRAM cache between processor registers and DRAM improve the system’s cost/performance balance?
Caches Online Quiz Questions
Use this free practice quiz with 20 questions to review Caches, test your knowledge, and prepare for your next test or exam.
True or false: Every cache miss is the first access to that memory line.
- A
True
- B
False
Select all statements that correctly describe temporal or spatial locality.
- A
Repeatedly accessing the same memory location soon after its previous access demonstrates temporal locality.
- B
Reading consecutive array elements demonstrates spatial locality.
- C
Reading one value makes an unrelated, far-away address an example of spatial locality.
- D
Temporal locality means that nearby addresses are likely to be accessed together.
A cache uses 16-byte blocks. Loading 0x120 misses and fills its block, which covers addresses 0x120 through 0x12F. The next access loads 0x121, with no intervening accesses. Is the second access a hit or a miss?
For a direct-mapped cache lookup to be a hit, the selected entry’s valid bit must be , and its stored tag must the requested address’s tag.
A direct-mapped cache designer is choosing between the stripe and chunk mappings described in the material. Which reason supports choosing stripe mapping?
- A
Stripe mapping distributes neighboring addresses across different indices, helping the cache serve spatially local accesses.
- B
Chunk mapping distributes neighboring addresses across different indices, helping the cache serve spatially local accesses.
- C
Stripe mapping sends every address to the same index, reducing conflicts from nearby data.
- D
Chunk mapping guarantees that every memory address has a unique cache index.
A direct-mapped cache has 256 entries, 16-byte blocks, and 32-bit addresses. Fill in the number of bits in each field: block offset = , index = , and tag = .
A cache has a hit time of 1 ns and a miss penalty of 50 ns. If 95% of accesses hit, calculate the average memory access time using tavg=thit+rmiss×tmiss. Enter the numerical value in nanoseconds.
True or false: In a write-back cache, every store hit immediately sends the updated data to main memory.
- A
True
- B
False
A cache has 512 total entries and is 2-way set-associative. How many sets does it contain?
- A
128
- B
256
- C
510
- D
1,024
Select all statements that correctly distinguish the three classic categories of cache misses.
- A
A cold miss occurs on the first access to a given cache line.
- B
A conflict miss can occur when lines compete for the same set and one evicts another needed later.
- C
A capacity miss can persist in a fully associative cache when the working set exceeds the cache’s capacity.
- D
Every miss after an eviction is necessarily a capacity miss.
Why is a fully associative cache generally practical only when it is small?
- A
It avoids searching entries because each memory block has a predetermined index.
- B
It is costly only because it requires a replacement policy when the cache is full.
- C
It must search all entries on every access, making the hardware large, hot, and slow as the cache grows.
- D
It needs fewer tag bits than a direct-mapped cache with the same block size.
When evicting an entry from a write-back cache, what should happen if the entry is dirty?
- A
Write the entry back to main memory whether it is clean or dirty.
- B
Write the entry back to main memory if it is dirty; if it is clean, no write-back is needed.
- C
Discard the entry without writing it back, because the dirty bit only affects hits.
- D
Set the valid bit to zero and leave main memory unchanged in both cases.
A designer increases the block size of a direct-mapped cache while keeping total cache capacity fixed. Explain how this change can affect cold misses, conflict misses, tag overhead, and miss penalty, and why its overall effect on performance is not always an improvement.
A loop repeatedly updates the same variable, total, on each iteration. Which form of locality best describes these accesses to total?
- A
Spatial locality, because the accesses are to nearby memory addresses.
- B
Temporal locality, because the same memory address is accessed repeatedly.
- C
Neither form of locality, because the variable is updated.
- D
Both forms, because every loop access is to a different address.
A direct-mapped cache uses 32-bit byte addresses, has 256 entries, and stores 16-byte blocks. Which address-field breakdown is correct, listed as offset, index, and tag?
- A
Offset: 8 bits; index: 4 bits; tag: 20 bits.
- B
Offset: 4 bits; index: 20 bits; tag: 8 bits.
- C
Offset: 4 bits; index: 8 bits; tag: 20 bits.
- D
Offset: 8 bits; index: 8 bits; tag: 16 bits.
A cache fetches an entire 16-byte block on a load miss. Starting with an empty cache, a program loads one byte and then immediately loads the next byte in memory. What happens, assuming both bytes belong to the same block?
- A
The first access misses; the second hits because it is in the block just fetched.
- B
Both accesses miss because each address is a distinct byte.
- C
The first access hits; the second misses because it has a different offset.
- D
Both accesses hit because they are adjacent in memory.
A set-associative cache has 512 total entries and 4 ways per set. How many sets does it have? Enter the number of sets.
For a fixed cache capacity, a fully associative cache can avoid conflict misses, although it can still experience capacity misses.
- A
True
- B
False
A fully associative cache has three entries and uses least-recently used (LRU) replacement. Starting with an empty cache, it accesses blocks A, B, C, A, and then D. Which block is evicted when D is loaded?
Related study packs and tools
- Study guide
02 — Information and Representation
A progressive guide to how computers encode numbers, text, images, and sound as binary data, including the trade-offs and limits of digital representation.
- Quiz
2 Digital Logic
A 14-question medium-difficulty quiz on Boolean algebra, logic gates, truth tables, and combinational circuits.
- Flashcards
03 — Python Programming Fundamentals
A focused set of flashcards covering Python variables, data types, expressions, control flow, functions, input, output, and common programming practices.
- Study guide
3 CPU Architecture
Learn how registers, the ALU, datapath connections, and control logic work together to fetch and execute CPU instructions.
- Study guide
05 — Data Structures: Concepts, Operations, and Trade-Offs
A structured guide to the main data structures, their operations, efficiency trade-offs, representations, and practical selection criteria.
- Study guide
6 Computer Memory
Learn how computer memory stores and addresses information, how RAM and ROM differ, and how caches and the memory hierarchy balance speed, capacity, and cost.
- Study guide
07 Trees and Binary Search Trees
A progressive guide to tree structure, binary-tree traversals, binary search tree operations, deletion, balancing, and the way tree height determines time and space costs.
- Flashcards
08 — Discrete Mathematics for Computer Science
A focused review of propositional logic, quantifiers, sets, relations, functions, and foundational proof methods in discrete mathematics for computer science.
- Study guide
8 Software Documentation
Learn how to choose, structure, document, and maintain software documentation for users, developers, integrators, and operators.
- Study guide
9 Sorting Algorithms
A structured guide to comparison-based sorting algorithms, their complexity, stability, memory use, and practical selection criteria.
- Study guide
10 — Data, Systems, and Applications
A progression through how data is organized, searched, exposed through software interfaces, and managed through abstraction layers in modern computer systems.
- Quiz
12 — Foundations Capstone
A medium-difficulty quiz on integrating problem definition, representation, algorithms, complexity analysis, testing, correctness, ethical evaluation, and documentation in a computer science capstone.