Skip to content
Related Articles
Open in App
Not now

Related Articles

GATE | GATE CS 1999 | Question 22

Improve Article
Save Article
Like Article
  • Difficulty Level : Basic
  • Last Updated : 25 Nov, 2020
Improve Article
Save Article
Like Article

The main memory of a computer has 2 cm blocks while the cache has 2c blocks. If the cache uses the set associative mapping scheme with 2 blocks per set, then the 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 2c) of the cache
(D) (k mod 2cm) of the cache

Answer: (B)

Explanation: Given,
Main memory = 2 C M blocks
Cache Size = 2 C blocks

Set Associative Mapping is 2-way set associative. Therefore Number of lines per set = 2 {i.e., Set size}.

Number of sets,

= Cache size / Set size
= 2 C / 2 

Number of sets = C in the cache.

kth block of the main memory maps to (K mod C)th set of the main memory .

i = k modulo c
i = cache set number
k = main memory block number
c = number of sets in the cache 

This solution is contributed by VIVEK YEMUL.

Quiz of this Question

My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!