Virtual Memory -Neha Jain 11/14/05 ELEC6200-001 1 Topics Covered Introduction Virtual Memory Address Translation Thrashing and Protection References 11/14/05 ELEC6200-001 2 Introduction Memory Hierarchy CPU Functional units Registers Internal cache Memory Content: Cache Main Mem Secondary Mem Memory Parameters: Access Time: increase with distance from CPU Cost/Bit: decrease with distance from CPU External Cache Capacity: increase with distance from CPU Main Memory Secondary Memory (Disk) 11/14/05 Cache : use SRAM (faster and costly) Main Memory : use DRAM (slower and cheap) ELEC6200-001 3 Principle of Locality Temporal Locality : Item tend to be referenced again soon Spatial Locality : Nearby items tend to be referenced again soon Cache Memory -Takes advantage of principle of locality 11/14/05 ELEC6200-001 4 Virtual Memory A technique that uses main memory as a “cache” for secondary storage Basic Terminology 11/14/05 Page : Fixed number of bytes recognized by operating system Page Fault : Occurs when accessed page is not in main memory Physical Address : Address in main memory Virtual Address: Addresses that application programmers deal with and are translated by MMU to physical address ELEC6200-001 5 MMU: Memory management unit Virtual Address Physical address Cache Data Data Processor Physical address Main memory Virtual Address 31 30 29 28 27 ……………....13 12 11………….…….…2 1 0 Virtual Page Number Page Offset Translation 29 28 27 ……………………...13 12 11………….…….…2 1 0 Physical page number 11/14/05 Page Offset ELEC6200-001 Physical Address 6 Segmented Memory Memory Management Unit (MMU) S1 x Segment Table S3 S1 free S4 11/14/05 x free S2 S3 Physical Memory ELEC6200-001 7 Mapping Segmented Address Virtual Address Physical Memory Segment # Displacement Segment Table V prot limit base Protection Compare segment Limit to displacement + datum Physical address Segment# : specifies which segment to use( base address and length) Displacement : offset from base address for actual memory access 11/14/05 ELEC6200-001 8 Page table for address translation Virtual page number Page table Physical page or Valid disk address Physical memory 1 1 1 1 0 1 1 0 1 1 0 1 11/14/05 Disk storage ELEC6200-001 9 Page Tables The page table ,PC and registers specifies the state or process of a program 11/14/05 Swap Space : Space on hard diskELEC6200-001 for all the pages of a process 10 Making Address Translation Fast By Translation-lookaside Buffer 11/14/05 ELEC6200-001 11 TLBs and Caches 11/14/05 ELEC6200-001 12 Who handles page faults? Operating System (in system software) - Look up page table - Choose a physical page to replace - Bring referenced page from disk into chosen physical page 11/14/05 ELEC6200-001 13 Thrashing is a disaster and it occurs when program does not follow locality principle and continuously swaps pages from main memory to disk Protection - One of the way is by having different physical addresses for a same virtual address 11/14/05 ELEC6200-001 14 References http://www.eng.auburn.edu/users/nelsovp/ courses/elec5200_6200/ http://www.eng.auburn.edu/users/agrawvd/ E5200/course.html http://webster.cs.ucr.edu/AoA/Windows/HT ML/MemoryArchitecturea3.html 11/14/05 ELEC6200-001 15