984 views
5 votes
5 votes
A computer has a 128-entry $L_1$ TLB, 1024-entry $L_2$ TLB, and uses page size of 4KB. A program reads a 1MB array, one byte at a time from start to end, 10 times. Assuming the TLBs are directly mapped and initially empty, and no other memory is accessed, find TLB hits and misses of both $L_1$ and $L_2$ TLB (array is page aligned).

1 Answer

Best answer
6 votes
6 votes
The number of pages required for 1MB array with 4KB page size will be $2^{20}/2^{12}=2^{8}=256$ pages.

When program requests first byte, there will be TLB miss on both $L_1$ and $L_2$, and first page's translation will be brought to both TLBs.
When program requests second byte, its translation will be present in $L_1$, as whole of the page is brought in both TLBs, and a single page can contain 4KB = 4096 bytes.

This means there is 1 TLB miss in $L_1$ and $L_2$, and 4095 hits in $L_1$ and 0 hits in $L_2$ in first page.
This will continue for the remaining 255 pages. So $hit(L_1)=4095\times 256, miss(L_1)=256$
$hit(L_2)=0, miss(L_2)=256$

When the second iteration starts, $L_1$ will be having the last 128 page translations in it, whereas $L_2$ will have the translation of all the pages, so whenever there will be a TLB miss in $L_1$, $L_2$ will provide the data.
So for 256 pages, $hit(L_1)=4095\times 256, miss(L_1)=256$
$hit(L_2)=256, miss(L_2)=0$

This happens for a total of 10 times, so finally:

$hit(L_1)=10\times 4095\times 256, miss(L_1)=10\times 256$
$hit(L_2)=9\times 256, miss(L_2)=256$

Related questions

0 votes
0 votes
0 answers
4