40 likes | 188 Vues
Virtual memory plays a critical role in modern computing by enabling efficient and safe memory sharing among multiple programs while allowing individual programs to exceed the size of main memory. Key concepts include pages, page faults, and the translation of virtual addresses to physical addresses. Each program maintains a page table to index virtual addresses. The Translation Lookaside Buffer (TLB) enhances address translation speed by caching recent address mappings, reducing page fault penalties. This system optimizes memory usage and ensures smooth program execution even under constrained resources.
E N D
Virtual Memory (Sec. 5.7) Two Major Motivations: • Allow efficient and safe sharing of memory among multiple programs • Allow a single program to exceed the size of main memory Some Terminology: • A virtual memory block is called a page • A miss is called a page fault • The CPU produces a virtual address, which is translated to a physical address • A physical address is used to access the main memory
31 30 - - - - - - - - - 12 11 - - - -- - - - - - - 0 Virtual Page No. Physical Page No. Page off set Page off set Translate 29 28 12 11 0 Mapping Virtual Address to Physical Address Virtual Address Physical Address Page size = 4 KB Virtual address space = 4 GB Physical address space = 1 GB
Page Table • Penalty for a page fault is very high • So, we optimize page placement to reduce fault rate • Hence, motivation to use fully associative placement • Pages are located using a ‘page table’ • Page table is indexed with the page number of Virtual Addresses and contains the page numbers of Physical Addresses as data • Each program has its own page table
Fast Address Translation – Translation Look-aside Buffer (TLB) • A special cache is used for address translation, called Translation Look-aside Buffer (TLB) • Each tag entry of TLB holds portion of virtual page number • Each data entry of TLB holds a physical page number • On every reference, the TLB is searched to find the desired virtual page number • If it is a hit, continue • If it is a miss, check the Page Table • If it is a page fault, go to exception handling • If no page fault, load the TLB with the desired entry