Given , page fault service time (here referred to as page swap time since
majority of page fault service time is in swap only , other task include like page replacement from
the main memory , updation of page tables etc) = 5000 ns
page fault rate = 10% = 0.1
TLB access time = 20 ns
TLB hit rate = 95 % = 0.95
Main memory access time = 80 ns
Let us break the solution into subproblems .
Case 1 : Page fault does not occur
This has further cases :
a) TLB hit occurs :
So effective time when TLB hit occurs = TLB hit rate* [TLB access time + Main memory access time ]
= 0.95 * [20 + 80]
= 0.95 * [100]
= 95 ns ............(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 it is given that 2 level paging is used , so 2 main memory access times are required since page tables are stored in main memory.
So effective time when TLB miss occurs = TLB miss rate* [TLB access time + 2 main memory access time(due to page table) + 1 main memory access time to read the actual data / instruction ]
= 0.05 * [20 + 80 + 80 + 80]
= 0.05 * [260]
= 13 ns ...............(2)
So combining (1) and (2) ,
Effective time if page fault does not occur = 95 + 13
= 108 ns .................(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 , 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 = 5000 + 108
= 5108 ns ...............(4)
But page fault occurs only 10 % 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.9 * 108 + 0.1 * 5108
= 608 ns
Hence time required effectively = 608 ns