3,480 views
5 votes
5 votes
Consider a Memory Management System where TLB hit rate is 90% whose access time is 1 cycle. The hit ratio for cache is 80% and if access time is 1 cycle. The page fault rate when there is a miss in both TLB and cache is 2%. Main memory access time is 20 cycles. Hard drive access time is 500 cycles. The page tables are always kept in Memory. The TLB accesses and cache acesses are sequential. The average memory access time when the cache is virtually addressed is __________ cycle. (Upto 2 decimal places)

2 Answers

4 votes
4 votes

Given , page fault service time = 500 cycles

           page fault rate             =  2%  =  0.02

          TLB access time          =  1 cycle

          TLB hit rate                  =  90 %  = 0.9

         Cache access time        =  1 cycle

         Cache hit rate                = 80 %  =  0.8

         Main memory access time  = 20 cycles

Let us break the solution into subproblems .

Case 1 : Page fault does not occur

This has further cases :

a) TLB hit occurs :

In this case , page tables need not be accessed hence we check that there may be cache hit or cache miss , so again 2 cases within it.

So effective time when TLB hit occurs = TLB hit rate*  [TLB access time + Cache hit rate(Cache access time) +

                                                             Cache miss rate * (Cache access time + Main memory access time) ]

                                                        =  0.9 * [1 + 0.8*1 + 0.2*(1 + 20) ]

                                                        =  0.9 * [1 + 0.8 +  4.2]

                                                        =  0.9 * 6

                                                        =  5.4 cycles          ............(1)

Now 

b) TLB miss occurs :

So in this case the page tables access time which are in main memory are also going to be counted .Since nothing is given about level of paging so we assume we have 1 level of paging only , so 1 main memory access time is required since page tables are stored in main memory. 

So effective time when TLB miss occurs = TLB miss rate*  [TLB access time + 1 main memory access time(due to page table)                             + Cache hit rate(Cache access time) + Cache miss rate * (Cache access time + Main memory access time) ]

                                                           = 0.1 * [ 1 + 20 + 0.8 + 0.2 * 21 ]

                                                           = 0.1 * [ 1 + 20 + 5]

                                                           = 0.1 * 26

                                                           = 2.6 cycles                                                     ...............(2)

So combining (1) and (2) ,

 Effective time if page fault does not occur  =  5.4 + 2.6

                                                               =  8 cycles                                                   .................(3)

Now we come to case 2) 

Case 2  : Page fault occurs :

If page fault occurs , then in addition to what have we done in earlier steps , we also require page fault service time

So time required in this case :  Page fault service time + effective time calculated in case a) [as we come to know later that page fault has occured , so we have accessed TLB , page tables , cache memory , main memory as required and as the case may be before knowing that page fault has occured ]

So ,

Time required in case page fault occurs     =     500 + 8  

                                                              =     508 cycles                    ...............(4) 

But page fault occurs only 2 % of the time.Hence,

Effective time required         =      Page hit rate * time calculated in case 1 + page fault rate(or miss rate) * time found in case 2

                                          =      0.98 * 8   +   0.02 * 508

                                          =      7.84   +    10.16

                                          =      18 cycles

Hence no of cycles required effectively  = 18 cycles

reshown by
0 votes
0 votes
Here Cache is read before Tlb and after miss in both it is taken from hard drive, So I guess the Solution will be

Cache(hit) * cache Time + Cache(miss) { Tlb(hit) [ tlb time + memory time] + tlb(miss) [ 20+ .02*500 ] }   

??

Related questions

0 votes
0 votes
1 answer
1
0 votes
0 votes
1 answer
2
0 votes
0 votes
1 answer
3
rayhanrjt asked Dec 29, 2022
408 views
What is the relationship between paging and virtual memory?A Virtual memory came before pagingB When pages are created in disks, it is called a virtual memory? C Virtual ...