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:

  1. A.

    (k mod m) of the cache

  2. B.

    (k mod c) of the cache

  3. C.

    (k mod 2^c) of the cache

  4. 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.

Explore the full course: Gate Guidance By Sanchit Sir