edited by
15,100 views
17 votes
17 votes

Consider a small two-way set-associative cache memory, consisting of four blocks. For choosing the block to be replaced, use the least recently used (LRU) scheme. The number of cache misses for the following sequence of block addresses is:

$8, 12, 0, 12, 8$.

  1. $2$
  2. $3$
  3. $4$
  4. $5$
edited by

3 Answers

Best answer
29 votes
29 votes
We have $4$ blocks and $2$ blocks in a set

$\implies$ there are $2$ sets. So blocks will go to sets as follows:
$$\begin{array}{|c|c|} \hline \textbf {Set Number} &  \textbf{Block Number} \\\hline \text{0} & \text{0,8,12}  \\\hline\text{1} &  \\\hline \end{array}$$
Since the lowest bit of block address is used for indexing into the set, so $8, 12$ and $0$ first miss in cache with $0$ replacing $8$ (there are two slots in each set due to $2-\text{way}$ set) and then $12$ hits in cache and $8$ again misses. So, totally $4$ misses.

Correct Answer: $C$
edited by
5 votes
5 votes
2 way set associative

4 blocks

Set size = # of blocks / # of sets

            = 4/2 = 2

So Block addresses will be divided by 2 ... On the basis of their remainder we will place those blocks in the sets .. applying LRU approach ... answer will be 4 ..
Answer:

Related questions

59 votes
59 votes
4 answers
1
go_editor asked Apr 24, 2016
19,515 views
Consider the following program segment for a hypothetical CPU having three user registers $R_1, R_2$ and $R_3.$\begin{array}{|l|l|c|} \hline \text {Instruction} & \text...
35 votes
35 votes
3 answers
2
52 votes
52 votes
10 answers
3