430 likes | 434 Views
Operating Systems. Operating Systems. Unit 7: Virtual Memory organization. Evolution of memory organization. Virtual Memory concept. Solves problem of limited memory space Creates illusion of more memory than exists Creates 2 types of addresses Virtual addresses Referenced by processes
E N D
Operating Systems Operating Systems Unit 7: Virtual Memory organization
Evolution of memory organization COP 5994 - Operating Systems
Virtual Memory concept • Solves problem of limited memory space • Creates illusion of more memory than exists • Creates 2 types of addresses • Virtual addresses • Referenced by processes • Physical addresses • Describes locations in main memory • Memory management unit (MMU) • Dynamic address translation • Translates virtual addresses to physical address COP 5994 - Operating Systems
Two-level Storage • backing store: • maintained on hard drive • contains complete virtual memory • real memory: • portion of virtual memory that is currently in use • Process can only access real memory • Management of mapping is essential COP 5994 - Operating Systems
Two-level Storage COP 5994 - Operating Systems
Address Translation • Mapping virtual addresses to real addresses • need address translation map per process • Address translation maps • Indicate which regions of a process’s virtual address space are currently in main memory and where they are located COP 5994 - Operating Systems
Mapping based on block COP 5994 - Operating Systems
Concept: block map table • address translation map is table with • block number • actual location of block in memory • typical implementation • block number is offset from table origin • table entries contain block location in memory COP 5994 - Operating Systems
Concept: virtual address • structure of virtual address: • b is the block number in virtual memory • d is the displacement from the start of block b at which the referenced item is located COP 5994 - Operating Systems
Block Mapping Process COP 5994 - Operating Systems
Blocks ? • Pages • Blocks are fixed size • Technique is called paging • Segments • Blocks maybe of different size • Technique is called segmentation COP 5994 - Operating Systems
Paging • Paging uses fixed-size block mapping: • Virtual address in paging system: v = (p, d) • p is the number of the page in virtual memory on which the referenced item resides • d is the displacement from the start of page p at which the referenced item is located COP 5994 - Operating Systems
Page Frame: page in real memory • Fixed-size block of main memory • Aligned with page size multiple COP 5994 - Operating Systems
Page to Frame correspondence COP 5994 - Operating Systems
Page Table Entry (PTE) • maps virtual page p to page frame p´ • Contains bit to indicate if page is in real memory • Term: Page Fault • access to memory location on page that is not in real memory COP 5994 - Operating Systems
Page Address Translation • Direct Mapping • Associative Memory • Translation Lookaside Buffer • Concerns: • memory access speed • size of page table COP 5994 - Operating Systems
Address Translation by Direct Mapping COP 5994 - Operating Systems
Page Table size • address size: 4 bytes bytes virtual memory amount: 4GB • Page size: 4k pages in virtual memory • PTE size: 8 bytes bytes maximum page table size: 8MB • Page table will not fit into processor cache COP 5994 - Operating Systems
Page Table size • address size: 8 bytes bytes virtual memory amount • Page size: 4k pages in virtual memory • PTE size: 16 bytes bytes maximum page table size • Page table will not fit into processor cache COP 5994 - Operating Systems
Address Translation by Associative Mapping COP 5994 - Operating Systems
Combination: Direct/Associative Mapping Experience shows: TLB size of 64 or 128 Can reach 90% of associative mapping performance COP 5994 - Operating Systems
Page Address Translation: concerns • memory access speed • consider cache speed • size of page table • 32 bit vs. 64 bit • use of memory space • locality of memory references • sparseness • advanced approaches • multi-level page tables • inverted page table COP 5994 - Operating Systems
Multilevel Page Tables • Hierarchy of page tables • Each level containing a table that stores pointers to tables in the level below • Bottom-most level comprised of tables containing address translations • Can reduce memory overhead compared to direct-mapping system • page table does not have to be contiguous COP 5994 - Operating Systems
Multilevel Page Tables COP 5994 - Operating Systems
Inverted Page Tables • One inverted page table stores one PTE in memory for each page frame in the system • Inverted relative to traditional page tables • Uses hash functions to map virtual page to inverted page table entry COP 5994 - Operating Systems
Inverted Page Tables COP 5994 - Operating Systems
Inverted Page Tables • Hash collisions increase memory accesses • Collisions can be reduced by increasing the range of the hash function • Cannot increase the size of the inverted page table because it must store exactly one PTE for each page frame • trick: hash anchor table • one more level of indirection COP 5994 - Operating Systems
Inverted Page Tables with hash anchor table COP 5994 - Operating Systems
Also: Page Sharing • programs may share common pages • data and/or instructions • pages marked as sharable or nonsharable COP 5994 - Operating Systems
Segmentation • based on variable-size segments • contiguous block of process’ address space • data, text, stack • process can run if current segment(s) is in main memory COP 5994 - Operating Systems
Segmentation COP 5994 - Operating Systems
Segmentation • virtual memory address v = (s, d) • s is the segment number in virtual memory • d is the displacement within segment s at which the referenced item is located COP 5994 - Operating Systems
Address Translation by Direct Mapping COP 5994 - Operating Systems
Segment map table entry • maps segment s to real memory address s´ • has resident bit to indicate segment is in memory • If so, it stores the segment base address • Otherwise, it stores the location of the segment on secondary storage • has segment length field • useful to protect memory outside of segment COP 5994 - Operating Systems
Segment map table entry COP 5994 - Operating Systems
Segment map table entry: protection COP 5994 - Operating Systems
Also: Segment Sharing Caution: segment protection COP 5994 - Operating Systems
Combination: Segmentation/Paging Systems • Segments occupy one or more pages • All pages of segment need not be in main memory at once • Pages contiguous in virtual memory need not be contiguous in main memory COP 5994 - Operating Systems
Virtual memory address • s is segment number • p is page number within segment • d is displacement within page at which desired item located COP 5994 - Operating Systems
Address Translation COP 5994 - Operating Systems
System-wide Table Structure COP 5994 - Operating Systems
Sharing and Protection • Page replacement requires updates to several tables • Protection checking is complex COP 5994 - Operating Systems
Agenda for next week: • next week: • Chapter 11: Virtual Memory Management • Read ahead ! COP 5994 - Operating Systems