150 likes | 346 Views
Virtual Memory. -Neha Jain. Topics Covered. Introduction Virtual Memory Address Translation Thrashing and Protection References. Introduction. Memory Hierarchy. CPU. Memory Content : Cache Main Mem Secondary Mem. Functional units.
E N D
Virtual Memory -Neha Jain ELEC6200-001
Topics Covered • Introduction • Virtual Memory • Address Translation • Thrashing and Protection • References ELEC6200-001
Introduction • Memory Hierarchy CPU Memory Content: Cache Main Mem Secondary Mem Functional units Registers Memory Parameters: Access Time: increase with distance from CPU Cost/Bit: decrease with distance from CPU Capacity: increase with distance from CPU Internal cache External Cache Main Memory Cache : use SRAM (faster and costly) Main Memory : use DRAM (slower and cheap) Secondary Memory (Disk) ELEC6200-001
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 ELEC6200-001
Virtual Memory • A technique that uses main memory as a “cache” for secondary storage • Basic Terminology • 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
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 Page Offset MMU: Memory management unit Physical address Virtual Address Cache Data Processor Physical address Data Main memory Virtual Address ELEC6200-001 Physical Address
Physical Memory Memory Management Unit (MMU) S1 x S3 free S2 S3 x S1 Segment Table free S4 Segmented Memory ELEC6200-001
Virtual Address Physical Memory Segment # Displacement Segment Table + V prot limit base datum Protection Physical address Compare segment Limit to displacement Mapping Segmented Address Segment# : specifies which segment to use( base address and length) Displacement: offset from base address for actual memory access ELEC6200-001
P a g e t a b l e P h y s i c a l m e m o r y P h y s i c a l p a g e o r d i s k a d d r e s s Page table for address translation V i r t u a l p a g e n u m b e r V a l i d 1 1 1 1 0 1 1 0 D i s k s t o r a g e 1 1 0 1 ELEC6200-001
Page Tables The page table ,PC and registers specifies the state or process of a program Swap Space : Space on hard disk for all the pages of a process ELEC6200-001
Making Address Translation Fast • By Translation-lookaside Buffer ELEC6200-001
TLBs and Caches ELEC6200-001
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 ELEC6200-001
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 ELEC6200-001
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/HTML/MemoryArchitecturea3.html ELEC6200-001