Virtual Memory: S. Dandamudi
Virtual Memory: S. Dandamudi
Chapter 18
S. Dandamudi
Outline
Introduction
Virtual memory concepts
Translation lookaside
buffer
2003
Introduction
Virtual memory deals with the main memory size
limitations
Provides an illusion of having more memory than the
systems RAM
Virtual memory separates logical memory from
physical memory
Logical memory: A processs view of memory
Physical memory: The processors view of memory
2003
Introduction (contd)
Virtual memory
Automates the overlay management process
Big relief to programmers
Protection
Programs are isolated from each other
A benefit of working in their own address spaces
Protection can be easily implemented
2003
Introduction (contd)
Principles involved are similar to the cache
memory systems
Details are quite different
Due to different objectives
Implementation is different
Due to different lower-level memory (disk)
Several orders of magnitude slower
2003
Examples
PowerPC
48-bit virtual address
32-bit physical address
Pentium
Both are 32-bit addresses
But uses
segmentation
2003
2003
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
An example
mapping of 32-bit
virtual address to
24-bit physical
address
2003
Virtual to
physical
address
mapping
2003
2003
2003
Several policies
2003
FIFO
Second chance
NFU
LRU (popular)
Pseudo-LRU implementation approximates LRU
2003
Unacceptable overhead
Improvement
Use virtual page number as index into the page table
Valid bit
Indicates whether the page is in memory
As in cache memory
Dirty bit
Indicates whether the page has been modified
As in cache memory
2003
Owner information
Needed to implement proper access control
Protection bits
Indicates type of privilege
Read-only, execute, read/write
Example: PowerPC uses three protection bits
Controls various types of access to user- and supervisormode access requests
2003
2003
Translation
using a TLB
2003
2003
Three-level
hierarchical
page table
2003
Examples
Pentium
2-level hierarchy
Details later
Alpha
4-level hierarchy
2003
2003
2003
2003
Segmentation
Virtual address space is linear and 1-dimensional
Segmentation adds a second dimension
Segmentation (contd)
Pentium and PowerPC support segmented-memory
architecture
Paging is transparent to programmer
Segmentation is not
Pentium assembly programming makes it obvious
Uses three segments: data, code, and stack
2003
Segmentation (contd)
Dynamic data structure allocation
2003
Example Implementations
Pentium
Supports both paging and segmentation
Paging can turned off
Segmentation can be turned off
2003
Pentiums logical
to physical address
translation
2003
2003
2003
2003
2003
PowerPCs logical
to physical address
translation process
2003
2003
2003
2003
Virtual to physical
address translation
with 4 KB pages
2003
Virtual to physical
address translation
with 16 MB pages
2003
MIPS TLB
entry format
2003
Indexed
Selects the entry specified
2003