Three Types of Cache Misses
Without explaining more lets directly go to some examples:
Consider a physical memory of $1\; MB$ size and a direct mapped cache of $8\; KB$ size with block size $32$ bytes. That is in one go $32$ bytes of data will be taken from/trasferred to main memory to/from cache. This means there are $1\;MB/8\; KB = 128$ blocks in main memory corresponding to a single cache block. Since $128$ memory blocks can map to a single cache entry, this means we need $\log_2 128 = 7$ tag bits.
Lets see how the cache misses go.
Let there be a sequence of block accesses given by
$$2, 216, 100, 256, 2048, 728, 256, 216$$
Since physical memory is 1 MB we need 20 bits for byte addressing. Out of these 5 bits are taken by a cache block (of size 32 bytes). So, remaining 15 bits are used for block addressing (means the block address can range from 0 – 32767)
If values are in decimal consider dividing and if they are in hexa-decimal consider removing the lower bits
No. of blocks in cache $= 8\; KB / 32 B = 256$
Now, to find which cache block a memory block goes, we just have to do $\boxed{\mod 256}$ because the set/index bits of the cache are lower bits and tag bits are upper (as mentioned earlier for utilizing any spatial locality).
Thus $$\begin{array}{c|c} 2& 2\\216 & 216 \\ 100 & 100 \\ 256 & 0 \\2048 & 0 \\ 728 & 216 \\256 & 0 \\ 216 & 216\end{array}.$$
Now, lets classify the misses happened here:
$$\begin{array}{c|c|c} 2& 2 & \text{Compulsory Miss}\\216 & 216& \text{Compulsory Miss} \\ 100 & 100& \text{Compulsory Miss}\\ 256 & 0& \text{Compulsory Miss}\\2048 & 0& \text{Compulsory Miss}\\ 728 & 216& \text{Compulsory Miss}\\256 & 0& \text{Conflict Miss}\\ 216 & 216& \text{Conflict Miss}\end{array}.$$
Now, why are the first $6$ accesses “Compulsory Misses”?
Why are the last $2$ accesses “Conflict Misses”?
Why are there no capacity misses?
CO & Architecture Preparation Resources for GATE CSE
This page shows all details regarding GATE CSE 2022 Admissions including results, admission offers and…
Source Add your Response Rank Predictor for GATE CSE 2021 Result Responses: GATE CSE 2021…
Best Books for GATE CSE with Relevant Chapters to Read Heads Up! These GATE CSE…
Indian Statistical Institute(ISI) offers M Tech in Computer Science with the Admission Test Codes MMA/PCA…
Indian Statistical Institute(ISI) offers Junior Research Fellowships (JRF) in Computer Science, Statistics, Mathematics, Quantitative Economics,…
Indian Statistical Institute(ISI) conduct the admission test for Postgraduate Diploma in Computer Applications(PGDCA) with the…