Consider a system with a processor and a KB direct mapped cache with block size of bytes. The system has a MB physical memory. Four words , and S are accessed by the processor in the same order times. That is, there are a total of memory references in the sequence
Assume that the cache memory is initially empty. The physical addresses of the words are given below ( word byte).
Which of the following statements is/are true?
Note: and
View worked solution
Answer: A;B
To determine the cache hit/miss behavior, we first analyze how the 24-bit physical address is split into Tag, Index, and Offset fields:
- Physical Address Space:
- Block Size: Offset (last hex digit)
- Number of Cache Blocks: Index (middle 2 hex digits)
- Tag Size: Tag (first 3 hex digits)
Using this mapping, we extract the fields for each address:
| Word | Address | Tag (12 bits) | Index (8 bits) | Offset (4 bits) |
|---|---|---|---|---|
| P | 0x845B32 | 0x845 | 0xB3 | 0x2 |
| Q | 0x845B26 | 0x845 | 0xB2 | 0x6 |
| R | 0x845B36 | 0x845 | 0xB3 | 0x6 |
| S | 0x846B32 | 0x846 | 0xB3 | 0x2 |
Note that P and R reside in the exact same cache block (same Tag 0x845 and Index 0xB3), while S maps to the same index 0xB3 but with a different Tag 0x846. Q maps to a different index 0xB2.
Let us trace the access sequence
- Iteration 1:
- P (Index
0xB3): Miss (cold). Block0x845B3is loaded. - Q (Index
0xB2): Miss (cold). Block0x845B2is loaded. - R (Index
0xB3): Hit (since block0x845B3is already in index0xB3). - S (Index
0xB3): Miss (conflict). Block0x846B3replaces block0x845B3.
- P (Index
- Iteration 2 to 10:
- P (Index
0xB3): Miss (conflict with S). Block0x845B3is loaded. - Q (Index
0xB2): Hit (block0x845B2remains undisturbed). - R (Index
0xB3): Hit (block0x845B3was just loaded by P). - S (Index
0xB3): Miss (conflict with P/R). Block0x846B3is loaded.
- P (Index
Thus:
- A is True: Every access to results in a cache miss.
- B is True: Every access to results in a cache hit.
- C is False: Only the first access to is a miss; the remaining 9 are hits.
- D is False: Every access to results in a cache miss.
Free practice · Your answers on this page are not saved.
