Consider a machine with a byte addressable main memory of bytes. Assume that a direct mapped data cache consisting of lines of bytes each is used in the system. A two-dimensional array of bytes is stored in the main memory starting from memory location . Assume that the data cache is initially empty. The complete array is accessed twice. Assume that the contents of the data cache do not change in between the two accesses.
How many data misses will occur in total?
View worked solution
Answer: C
To find the total number of cache misses, we first determine how the array is mapped to the cache blocks.
1. Memory Blocks Spanned by the Array:
- Array start address:
- Array size: bytes
- Array end address:
- Cache block size: bytes
- Starting memory block:
- Ending memory block:
- Total blocks spanned: blocks (from block 68 to 107)
2. First Access Pass:
Since the cache is initially empty, accessing these blocks sequentially results in compulsory misses.
The cache has lines (indexed to ). The blocks map to cache lines using :
- Blocks to map to lines to .
- Blocks to map to lines to .
- Blocks to map to lines to .
- Blocks to map to lines to (overwriting blocks to ).
3. Second Access Pass:
- Blocks to : Map to lines to (which currently hold blocks to ) misses.
- Blocks to : Map to lines to (which still hold blocks to ) misses.
- Blocks to : Map to lines to (which still hold blocks to ) misses.
- Blocks to : Map to lines to (which now hold blocks to loaded earlier in this pass) misses.
Total misses in the second pass = .
Total Misses:
Free practice · Your answers on this page are not saved.
