Virtual Memory-Unit 5
Virtual Memory-Unit 5
Unit 5
Memory Organization
— Virtual memory
Outline
• Introduction
• Virtual memory concepts
∗ Page replacement policies
∗ Write policy
∗ Page size tradeoff
∗ Page mapping
• Page table organization
∗ Page table entries
• Translation lookaside buffer
• Page table placement
∗ Searching hierarchical page tables
Introduction
• Cache memory enhances performance by providing faster
memory access speed.
• Virtual memory enhances performance by providing greater
memory capacity, without the expense of adding main
memory.
• Instead, a portion of a disk drive serves as an extension of
main memory.
• Virtual memory deals with the main memory size limitations
∗ Provides an illusion of having more memory than the
system’s RAM
∗ Virtual memory separates logical memory from
physical memory
» Logical memory: A process’s view of memory
» Physical memory: The processor’s view of memory
Introduction
• Virtual memory (VM) allows main memory (DRAM) to act
like a cache for secondary storage (magnetic disk).
• VM address translation a provides a mapping from the
virtual address of the processor to the physical address in
main memory or on disk.
• Virtual memory also provides
∗ Relocation
» Each program can have its own virtual address space
» Run-time details do not have any impact on code
generation
∗ Protection
» Programs are isolated from each other
» Protection can be easily implemented
Introduction
Implements a mapping
function
∗ Between virtual address
space and physical address
space
Introduction
Virtual address space is divided into fixed-size chunks
∗ These chunks are called virtual pages
∗ Virtual address is divided into
» Virtual page number
» Byte offset into a virtual page
Physical memory is also divided into similar-size
chunks
» These chunks are referred to as physical pages
» Physical address is divided into
– Physical page number
– Byte offset within a page
Virtual memory concepts
Page size is similar to cache line size
• Typical page size 4 KB
• Example
∗ 32-bit virtual address to 24-bit physical address
∗ If page size is 4 KB
» Page offset: 12 bits
» Virtual page number: 20 bits
» Physical page number: 12 bits
∗ Virtual memory maps 220 virtual pages to 212
physical pages
Virtual memory concepts
Virtual memory concepts
Virtual memory concepts