edited by
37,395 views
181 181 votes

An access sequence of cache block addresses is of length $N$ and contains n unique block addresses. The number of unique block addresses between two consecutive accesses to the same block address is bounded above by $k$. What is the miss ratio if the access sequence is passed through a cache of associativity $ A\geq k $ exercising least-recently-used replacement policy?

  1. $\left(\dfrac{n}{N}\right)$
  2. $\left(\dfrac{1}{N}\right)$
  3. $\left(\dfrac{1}{A}\right)$
  4. $\left(\dfrac{k}{n}\right)$

14 Answers

0 0 votes

Answer A.
The miss ratio in this case can be described by the formula:

Miss ratio = (n - A + 1) / N

This is because, when the associativity of the cache is greater than or equal to k, the cache will always contain the most recent k unique block addresses. Therefore, when a block address is accessed again, it will always be found in the cache. The only time a miss will occur is when the cache is full and the least recently used block address needs to be replaced. This will happen (n - A + 1) times over the course of the N accesses.

So, the formula for miss ratio is (n - A + 1) / N . where A is the associativity and N is the total number of block addresses.

0 0 votes

1. Understanding the Goal

First, let's define the miss ratio:

  • Miss Ratio = (Total Number of Misses) / (Total Number of Accesses)

The problem gives us the denominator right away:

  • The "access sequence... is of length $N$".

  • So, Total Number of Accesses = $N$.

Our entire job is to find the Total Number of Misses.


 

2. Analyzing the Types of Misses

 

There are three types of cache misses. Let's see which ones apply.

  1. Compulsory Misses (Cold Starts): This type of miss is unavoidable. It happens the very first time the program accesses a block of data. Since the data has never been seen before, it cannot possibly be in the cache.

  2. Conflict Misses: This is an avoidable miss. It happens when two blocks map to the same cache set, and one evicts the other, even though there is empty space elsewhere in the cache.

  3. Capacity Misses: This is an avoidable miss. It happens when the cache is simply too small to hold all the blocks the program is actively using, so it has to evict a block that it will need again soon.


 

3. Calculating the Misses

 

Let's use the information from the problem to count the misses.

A) How many Compulsory Misses?

  • The problem states the sequence "contains $n$ unique block addresses."

  • Each of these $n$ blocks must cause a miss on its very first access.

  • Total Compulsory Misses = $n$

 

B) How many Conflict/Capacity Misses?

This is the key to the problem. We need to figure out if any block, after being loaded, is ever evicted and then accessed again.

Let's look at the two conditions:

  1. Program Behavior: "The number of unique block addresses between two consecutive accesses to the same block address is bounded by $k$."

    • This means if you access block B, and then later access B again, the "stuff" in the middle (...) contains at most $k$ other unique blocks.

    • ... B, (X1, X2, ... Xk), B ...

  2. Hardware Specification: "a cache of associativity $A \ge k$ exercising least-recently-used (LRU) replacement policy."

    • This means our cache's sets can hold at least $k$ blocks. 

Let's trace a re-access in the worst-case scenario:

  1. Access B (First time): This is a Compulsory Miss. Block B is loaded into a set (say, Set 0). It is now the "Most Recently Used" (MRU).

  2. Access Other Blocks: The program now runs and accesses at most $k$ other unique blocks (X1, X2, ... Xk) before it needs B again.

  3. Worst-Case for B: The worst possible luck is that all $k$ of these other blocks map to the exact same set (Set 0).

  4. Analyze the Set (LRU):

    • Our set needs to hold B (which is now the LRU) plus the $k$ other blocks.

    • Total blocks the set needs to hold = $k+1$ (Block B + $k$ other blocks).

  5. Check the Hardware:

    • The problem guarantees our associativity $A$ is sufficient. (Even with the typo $A \ge k$, the clear intent is that the hardware ($A$) is large enough to handle the program's locality ($k$)).

    • Let's assume the question meant $A \ge k+1$ (which is the technically correct version of this problem).

    • Since the set can hold $k+1$ blocks (or more), and it needs to hold $k+1$ blocks, block B is not evicted. It will be the LRU, but it's still in the cache.

  6. Re-access B: The program comes back to access B. Since B was never evicted, this is a HIT.

This proves that no block is ever evicted and then re-accessed. The only misses that ever occur are the initial compulsory misses.

  • Total Conflict/Capacity Misses = 0


 

4. Final Calculation

  • Total Misses = (Compulsory Misses) + (Conflict/Capacity Misses)

  • Total Misses = $n + 0 = n$

  • Total Accesses = $N$

  • Miss Ratio = $n / N$

Answer:
Position:
Show:

Related questions

78 78 votes
11 answers 11 answers
33.4k
33.4k views
go_editor asked Sep 28, 2014
33,436 views
Consider a $6$-stage instruction pipeline, where all stages are perfectly balanced. Assume that there is no cycle-time overhead of pipelining. When an application is exec...
75 75 votes
9 answers 9 answers
39.9k
39.9k views
Kathleen asked Sep 13, 2014
39,911 views
The access times of the main memory and the Cache memory, in a computer system, are $500$ n sec and $50$ nsec, respectively. It is estimated that $80\%$ of the main memor...
70 70 votes
9 answers 9 answers
27.7k
27.7k views
go_editor asked Sep 28, 2014
27,694 views
Consider two processors $P_1$ and $P_2$ executing the same instruction set. Assume that under identical conditions, for the same input, a program running on $P_2$ takes $...
74 74 votes
8 answers 8 answers
31.3k
31.3k views
go_editor asked Sep 26, 2014
31,342 views
A machine has a $32\text{-bit}$ architecture, with $1\text{-word}$ long instructions. It has $64$ registers, each of which is $32$ bits long. It needs to support $45$ ins...