search
Log In
22 votes
4.1k views

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 block $k$ of the main memory maps to the set:

  1. $(k$ $mod$ $m)$ of the cache
  2. $(k$ $mod$ $c)$ of the cache
  3. $(k$ $mod$ $2c)$ of the cache
  4. $(k$ $mod$ $2 cm)$ of the cache
in CO and Architecture
edited by
4.1k views
0
K(bolck no.) mod c(no of set)
0

option B) (mod c) of the cache is the answer .

2 Answers

39 votes
 
Best answer
Number of cache blocks $= 2c$

Number of sets in cache $=\dfrac{2c}{2}=c$ since each set has $2$ blocks. Now, a block of main memory gets mapped to a set (associativity of $2$ just means there are space for $2$ memory blocks in a cache set), and we have $2\,cm$ blocks being mapped to $c$ sets. So, in each set $2m$ different main memory blocks can come and block $k$ of main memory will be mapped to $k \ mod \ c.$

Correct Answer: $B$

edited by
4
Answer should be (k mod c)
2
That was a silly mistake. Thanks :)
2
great explanation arjun sir
1
Nice Explanation Sir.
0

Shouldn’t the answer be $k\ mod\ 2c$ according to answer provided in https://gateoverflow.in/1442/gate2013-20. I agree that $k\ mod\ c$ is correct here. But both answers seem conceptually different to me. 

0

In the Gate 2013 question link you provided, the question is kth block of MM is mapped to which cache line, whereas in this question it is asked kth block of MM is mapped to which cache set. 

9 votes
Cache set no=(Main memory block no.) mod  (Total sets in cache)
total sets in cache=(total blocks in cache)/(total blocks in set)=(2c)/(2)=c
cache se no=(k) mod (c)=k mod c
Answer:

Related questions

30 votes
3 answers
1
4.7k views
The main difference(s) between a CISC and a RISC processor is/are that a RISC processor typically has fewer instructions has fewer addressing modes has more registers is easier to implement using hard-wired logic
asked Sep 23, 2014 in CO and Architecture Kathleen 4.7k views
16 votes
3 answers
2
2.7k views
Consider the following program fragment in the assembly language of a certain hypothetical processor. The processor has three general purpose registers $R1, R2$and $R3$. The meanings of the instructions are shown by comments (starting with ;) after the instructions. X: CMP R1, 0; ... $R3$ when control reaches $Z$?
asked Sep 24, 2014 in CO and Architecture Kathleen 2.7k views
29 votes
3 answers
3
4.4k views
An instruction pipeline consists of $4$ stages - Fetch $(F)$, Decode field $(D)$, Execute $(E)$ and Result Write $(W)$. The $5$ instructions in a certain instruction sequence need these stages for the different number of clock cycles as shown by the table below \begin{array}{ ... & \text{$1$} & \text{$2$} \\\hline \end{array} Find the number of clock cycles needed to perform the $5$ instructions.
asked Sep 24, 2014 in CO and Architecture Kathleen 4.4k views
40 votes
2 answers
4
7.9k views
A certain processor supports only the immediate and the direct addressing modes. Which of the following programming language features cannot be implemented on this processor? Pointers Arrays Records Recursive procedures with local variable
asked Sep 23, 2014 in CO and Architecture Kathleen 7.9k views
...