Questions: Cache Line Organization and Byte Offset

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

Two threads on different CPU cores write frequently to different variables stored 4 bytes apart in memory, within the same 64-byte cache line. Performance is mysteriously poor despite no shared data. What is the most likely cause?

AA data race — the threads are inadvertently accessing the same variable.
BFalse sharing — each core's write invalidates the entire cache line on the other core, even though they write to different bytes.
CCache thrashing — the two variables map to the same cache set, causing repeated tag evictions.
DAlignment error — the variables straddle word boundaries, causing split-register operations.
Question 2 Multiple Choice

For a 32-bit address with a 16 KB direct-mapped cache using 64-byte lines, how many bits are used for the offset, index, and tag respectively?

AOffset: 8, Index: 6, Tag: 18
BOffset: 6, Index: 8, Tag: 18
COffset: 6, Index: 14, Tag: 12
DOffset: 4, Index: 10, Tag: 18
Question 3 True / False

When a cache line is loaded on a miss, subsequent accesses to any other byte within that same line will be cache hits, requiring no additional memory fetches.

TTrue
FFalse
Question 4 True / False

Storing a variable in a smaller data type (e.g., char instead of double) guarantees it occupies fewer cache lines and will typically improve cache performance.

TTrue
FFalse
Question 5 Short Answer

Explain why caches fetch an entire cache line rather than just the single byte requested, and what assumption about memory access patterns this design exploits.

Think about your answer, then reveal below.