Vivek Seshadri 15740/18740 Computer Architecture Virtual Memory Vivek Seshadri 15740/18740 Computer Architecture
Readings Jacob & Mudge, “Virtual Memory in Contemporary Microprocessors,” IEEE Micro, 1998 Hennessy and Patterson, Appendix C.4-C.5
Why Virtual Memory? X CPU Load X Store Y Y Main Memory
Why Virtual Memory? Small available physical memory Contiguous address space Portability Protection Code & data OS data and application data One application’s data from another Sharing
Segmentation Segment: Base address + Size + Permissions Segments are re-locatable Can be copied from one location to another Each process is associated with a list of segments it can access
Virtual Memory All problems in computer science can be solved by another level of indirection - David Wheeler For an application to make progress, it is sufficient that the next instruction and the data required to execute the next instruction are present in main memory.
Virtual Memory CPU Load X Store Y Main Memory Virtual Address Space X
Virtual Memory Solves It All! Small available physical memory Large virtual address space (VAS)! Contiguous address space Data should be contiguous only in VAS Protection Different process -> Different VAS Sharing Map VAS to same location in physical memory
Implementation Pages Page tables Inverted page tables Large (to reduce mapping overhead) Page tables One entry per virtual page Hierarchical (to reduce size of page tables) Inverted page tables Speeding up translations Translation Look-aside Buffers (TLB)
Physical Memory Management Allocating pages Replacing pages (page fault) Swap space in disk Replacement policy LRU?
Virtual Memory & Caching Virtually-Indexed Virtually-Tagged Caches Virtual Page Number Offset Cacheline Tag Index Two processes can have the same virtual address
Solution - 1 Physically-Indexed Physically-tagged Cache Virtual Page Number Offset PhysicalPage Number Offset Cacheline Tag Index
Solution - 2 Virtually-Indexed Physically-tagged Cache Virtual Page Number Offset Physical Page Number Offset Cacheline Tag Index
Two virtual pages can map to the same physical page Synonyms Two virtual pages can map to the same physical page Virtual Page Number Offset Cacheline Tag Index