30 -OutlineMemory Access TimeMulti-Level Page TablesRecapRecap:Effective Access TimeAnnouncementsReading:Page ReplacementAlternative ApproachesMemory Access TimeMultilevel Page Tables1)3)4)2)MOS 3.3 - 3.7Quiz FridayVirtual Memory0xdeadb......0xbframe 0xbf......0xeefopage tableTLBphysicalmemoryvirtual addressphysical address0xbeefTLB is a specialized cache for page table entries.Define:thenComparison and loading is faster on hit.Miss causes page table access and TLB update.--:= TLB lookup timeis negligible (TLB lookup is very fast)is close to 1 (TLB misses very rare):= RAM access time:= hit ratio (fraction of TLB hits):= effective access timeAssuming:In practice, TLB can be designed so that missesare rare under most conditions, and the cost ofmisses is negligble.Page table size grows exponentially with number ofaddress bits.Multilevel Page Table --> page the page tableOnly portions of a page table need to be kept inRAM (rest don't exist or on disk)Downside: worst case, misses require 3+ accessesFortunately TLB can be designed for high hit rateLarger TLB increases hit ratioTLB hardware architecture affects hit ratio--fully associative, set associative, direct-mapped caches...e.g. 64-bit address, 4kB page => 2^52 pagessplit page number bits into primary andsecondary page numberdrastically reduce required memoryprimary page tablesecondary page tabledata-----primarysecondary...f...offsetosecondarypage tablesprimarypage tablephysicalmemoryvirtual addressphysical address...32-bit virtual address space.4kB page.4B page table entry.Application requires 12MB of RAM.Same size primary and secondary page table.What if there are 5 bits for the primary table, and15 bits for the secondary page?Note: typically the page table sizes are the samefor hardware cost reasons.Index table by frame number instead of pagenumber.What is the minimum RAM needed to store all thepage tables the application needs?ExerciseInverted Page Table (Frame Table)Hashed Page TablePollEvModern processors can use up to 4 or 5 levels ofpage tables(e.g. Intel Ice Lake & ARMv7-A)Hints:how big are the primary and secondary pagetables?how many total page tables are needed toaccess 12MB's worth of RAM?--1k1M1G1T1P1E= 2^10= 2^20= 2^30= 2^40= 2^50= 2^60Alternative ApproachesPage Replacementtable size proportional to RAM size(much smaller than virtual address space)translation requires linear search for page nummuch slowerTLB can help, but worst case is still terrible----0xdeadb......0xdeadbframe 0xbf......0xeefoframe tableTLBphysicalmemoryvirtual addressphysical address0xbeef0xblinearsearch0xbHash the page number to index into a linked listlinked list necessary for hash collisionsmust store both page and frame number--0xdeadb...f...0xeefopage tablephysicalmemoryvirtual addressphysical addresshashfunction3pfppffpfpfprocessOSdisk......free frame......page tablemain memoryi(1)(6)(2)(3)(4)(5)What happens when there is no free frame?Need some algorithm for determining which page toreplace with the one from disk.Page Replacement AlgorithmsGoal:Evaluation format:AlgorithmsDemand Paging & PrepagingRelated:Working Set ModelPage AllocationThrashingOptimalNot Recently Used2nd ChanceNot Frequently UsedClockAgingFirst In, First OutLeast Recently UsedExample:reference string:In:Out:select a victim page that will minimizefuture page faultsa string of memory references.(i.e. list of accessed pages)number of page faults the algorithm causesfor that string.replacing a page that will be needed again soon will causemore page faultsstr r0, 0x0123str r1, 0x1234str r2, 0x2345str r3, 0x3456ld r0, 0x0100ld r1, 0x1200str r4, 0x4567page 0page 1page 2page 3page 4...0x00000x10000x20000x30000x4000...0, 1, 2, 3, 0, 1, 4virtual memory------------