The main memory of a computer has 2^m blocks, while the cache has 2^c blocks.…
1999
The main memory of a computer has 2^m blocks, while the cache has 2^c blocks. If the cache uses a set-associative mapping scheme with 2 blocks per set, then block k of main memory maps to the set:
- A.
(k mod m) of the cache
- B.
(k mod c) of the cache
- C.
(k mod 2^c) of the cache
- D.
(k mod 2^(c - 1)) of the cache
Attempted by 38 students.
Show answer & explanation
Correct answer: D
The correct answer is: (k mod 2^(c - 1)) of the cache.
In set-associative mapping:
set number = (main-memory block number) mod (number of cache sets)
The cache has 2^c blocks in total.
Each set contains 2 blocks.
Therefore:
number of sets = 2^c / 2 = 2^(c - 1)
So main-memory block k maps to:
k mod 2^(c - 1)
Hence block k maps to the set (k mod 2^(c - 1)) of the cache.