Harvey Mudd CS 105 - Virtual Memory

Unformatted text preview:

Virtual MemoryMotivations for Virtual MemoryMotivation #1: DRAM As “Cache” for DiskLevels in Memory HierarchyDRAM vs. SRAM as a “Cache”Impact of Properties on DesignLocating an Object in a “Cache”Locating an Object in a “Cache”A System with Physical Memory OnlyA System with Virtual MemoryPage Faults (like “Cache Misses”)Servicing a Page FaultMotivation #2: Memory MgmtSolution: Separate Virtual Address SpacesContrast: Macintosh Memory ModelMacintosh Memory ManagementMac vs. VM-Based Memory ManagementMAC OS XMotivation #3: ProtectionVM Address TranslationVM Address Translation: HitVM Address Translation: MissSlide 23Page TablesAddress Translation via Page TablePage Table OperationSlide 27Slide 28Integrating VM and CacheSpeeding up Translation with a TLBAddress Translation with a TLBMulti-Level Page TablesMain ThemesVirtual MemoryVirtual MemoryTopicsTopicsMotivations for VMAddress translationAccelerating translation with TLBsVM1CS 105“Tour of the Black Holes of Computing!”– 2 –CS 105Motivations for Virtual MemoryMotivations for Virtual MemoryUse Physical DRAM as a Cache for the DiskUse Physical DRAM as a Cache for the DiskAddress space of a process can exceed physical memory sizeSum of address spaces of multiple processes can exceed physical memorySimplify Memory ManagementSimplify Memory ManagementMultiple processes resident in main memory.Each process with its own address spaceOnly “active” code and data is actually in memoryAllocate more memory to process as needed.Provide ProtectionProvide ProtectionOne process can’t interfere with another.Because they operate in different address spaces.User process cannot access privileged informationDifferent sections of address spaces have different permissions.– 3 –CS 105Motivation #1: DRAM As“Cache” for DiskMotivation #1: DRAM As“Cache” for DiskFull address space is quite large:Full address space is quite large:32-bit addresses: ~4,000,000,000 (4 billion) bytes64-bit addresses: ~16,000,000,000,000,000,000 (16 quintillion) bytesDisk storage is ~300X cheaper than DRAM storageDisk storage is ~300X cheaper than DRAM storage250 GB of DRAM: ~ $25,000 (667 MHz, late 2006 prices)250 GB of disk: ~ $55To access large amounts of data in a cost-effective manner, To access large amounts of data in a cost-effective manner, the bulk of the data must be stored on diskthe bulk of the data must be stored on disk1GB: ~$110 250 GB: ~$554 MB: ~$250DiskDRAMSRAM– 4 –CS 105Levels in Memory HierarchyLevels in Memory HierarchyCPUCPUregsregsCacheMemoryMemorydiskdisksize:speed:$/Mbyte:line size:32 B0.3 ns8 BRegister Cache Memory Disk Memory32 KB-4MB2 ns?$65/MB32 B2048 MB7.5 ns$0.10/MB4 KB250 GB8 ms$0.0002/MBlarger, slower, cheaper8 B 32 B 4 KBcache virtual memory– 5 –CS 105DRAM vs. SRAM as a “Cache”DRAM vs. SRAM as a “Cache”DRAM vs. disk is more extreme than SRAM vs. DRAMDRAM vs. disk is more extreme than SRAM vs. DRAMAccess latencies:DRAM ~10X slower than SRAMDisk ~100,000X slower than DRAMImportance of exploiting spatial locality:First byte is ~100,000X slower than successive bytes on disk»vs. ~4X improvement for page-mode vs. regular accesses to DRAMBottom line: Design decisions made for DRAM caches driven by enormous cost of missesDRAMSRAMDisk– 6 –CS 105Impact of Properties on DesignImpact of Properties on DesignIf DRAM was to be organized similar to an SRAM cache, how would If DRAM was to be organized similar to an SRAM cache, how would we set the following design parameters?we set the following design parameters?Line size?Large, since disk better at transferring large blocksAssociativity?High, to mimimize miss rateWrite through or write back?Write back, since can’t afford to perform small writes to diskWhat would the impact of these choices be on:What would the impact of these choices be on:miss rateExtremely low. << 1%hit timeMust match cache/DRAM performancemiss latencyVery high. ~20mstag storage overheadLow, relative to block size– 7 –CS 105Locating an Object in a “Cache”Locating an Object in a “Cache”SRAM CacheSRAM CacheTag stored with cache lineMaps from cache block to memory blocksFrom cached to uncached formSave a few bits by only storing tag of data blocks in cacheNo tag for block not in cacheHardware retrieves informationCan quickly match against multiple tagsXObject NameTag DataD 243X 17J 105••••••0:1:N-1:= X?“Cache”– 8 –CS 105Locating an Object in a “Cache” Locating an Object in a “Cache” Data243 17105•••0:1:N-1:XObject NameLocation•••D:J:X: 10On Disk“Cache”Page TableDRAM CacheDRAM CacheEach allocated page of virtual memory has entry in page tableMapping from virtual pages to physical pagesFrom uncached form to cached formPage table entry (tag) even if page not in memorySpecifies disk addressOnly way to indicate where to find pageOS retrieves information– 9 –CS 105A System withPhysical Memory OnlyA System withPhysical Memory OnlyExamples:Examples:Most Cray machines, early PCs, nearly all embedded systems, etc.Addresses generated by the CPU correspond directly to bytes in physical memoryCPU0:1:N-1:MemoryPhysicalAddresses– 10 –CS 105A System with Virtual MemoryA System with Virtual MemoryExamples:Examples:Workstations, servers, modern PCs, etc.Address Translation: Hardware converts virtual addresses to physical addresses via OS-managed lookup table (page table)CPU0:1:N-1:Memory0:1:P-1:Page TableDiskVirtualAddressesPhysicalAddresses– 11 –CS 105Page Faults (like “Cache Misses”)Page Faults (like “Cache Misses”)What if an object is on disk rather than in memory?What if an object is on disk rather than in memory?Page table entry indicates virtual address not in memoryOS exception handler invoked to move data from disk into memory - VM and Multiprogramming are symbioticCurrent process suspends, others can resumeOS has full control over placement, etc.CPUMemoryPage TableDiskVirtualAddressesPhysicalAddressesCPUMemoryPage TableDiskVirtualAddressesPhysicalAddressesBefore faultAfter fault– 12 –CS 105Servicing a Page FaultServicing a Page FaultProcessor Signals ControllerProcessor Signals ControllerRead block of length P starting at disk address X and store starting at memory address YRead OccursRead


View Full Document

Harvey Mudd CS 105 - Virtual Memory

Documents in this Course
Processes

Processes

25 pages

Processes

Processes

27 pages

Load more
Download Virtual Memory
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Virtual Memory and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Virtual Memory 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?