Back to the 2023 paper

Module 4: Memory Organization

20237m

Consider a direct mapped cache with 8 cache blocks (numbered 0-7). If the memory block requests are in the following order 3, 5, 2, 8, 0, 63, 9, 16, 20, 17, 25, 18, 30, 24, 2, 63, 5, 82, 17, 24. What would be the status of cache blocks (block numbers residing in cache) at the end of the sequence.

Worked SolutionAI Assisted

Direct Mapped Cache - Final Block Status

Cache size C=8C=8 blocks (0-7). Direct mapped: index = block mod 8.

Requests: 3,5,2,8,0,63,9,16,20,17,25,18,30,24,2,63,5,82,17,24

Trace:

# Block Index (mod8mod8) Action Cache state 0-7
- - - init [-,-,-,-,-,-,-,-]
1 3 3 miss [-,-,-,3,-,-,-,-]
2 5 5 miss [-,-,-,3,-,5,-,-]
3 2 2 miss [-,-,2,3,-,5,-,-]
4 8 0 miss [8,-,2,3,-,5,-,-]
5 0 0 miss evict 8 [0,-,2,3,-,5,-,-]
6 63 7 miss [0,-,2,3,-,5,-,63]
7 9 1 miss [0,9,2,3,-,5,-,63]
8 16 0 miss evict 0 [16,9,2,3,-,5,-,63]
9 20 4 miss [16,9,2,3,20,5,-,63]
10 17 1 miss evict 9 [16,17,2,3,20,5,-,63]
11 25 1 miss evict 17 [16,25,2,3,20,5,-,63]
12 18 2 miss evict 2 [16,25,18,3,20,5,-,63]
13 30 6 miss [16,25,18,3,20,5,30,63]
14 24 0 miss evict 16 [24,25,18,3,20,5,30,63]
15 2 2 miss evict 18 [24,25,2,3,20,5,30,63]
16 63 7 hit [24,25,2,3,20,5,30,63]
17 5 5 hit [24,25,2,3,20,5,30,63]
18 82 2 miss evict 2 [24,25,82,3,20,5,30,63]
19 17 1 miss evict 25 [24,17,82,3,20,5,30,63]
20 24 0 hit [24,17,82,3,20,5,30,63]

Final Cache Status

  • Block 0: 24
  • Block 1: 17
  • Block 2: 82
  • Block 3: 3
  • Block 4: 20
  • Block 5: 5
  • Block 6: 30
  • Block 7: 63

Vector form: [24, 17, 82, 3, 20, 5, 30, 63] for indices 0-7.

Hits = 3 (63,5,24); Misses = 17. No fully associative/LRU needed - direct mapped deterministic.

Similar questions

Budget AppAndroid App

Pocketly on Android

Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.