Professional Documents
Culture Documents
• A different approach
• Addresses all of the issues of previous topic
• Introduces new issues of its own
…
memory
…
• Make it possible to leave page X
frame Y
infrequently used parts of
virtual address space out
of physical memory
CS502 Spring 2006 Paging 4
Paging
• Processes see a contiguous virtual address space
• Memory Manager divides the virtual address
space into equal sized pieces called pages
• Memory Manager divides the physical address
space into equal sized pieces called frames
– Frame size usually a power of 2 between 512 and 8192
bytes
– Frame table
• One entry per frame of physical memory
• State
– Free
– Allocated – process(es)
• sizeof(page) = sizeof(frame)
CS502 Spring 2006 Paging 5
Paging – Address Translation
• Translating virtual addresses
– a virtual address has two parts: virtual page number &
offset
– virtual page number (VPN) is index into a page table
– page table entry contains page frame number (PFN)
– physical address is: startof(PFN) + offset
• Page tables
– Supported by MMU hardware
– Managed by the Memory Manager
– Map virtual page numbers to page frame numbers
• one page table entry (PTE) per page in virtual address space
• i.e., one PTE per VPN
page
page table frame 0
page
frame 1
physical address
page
page frame # F(PFN) offset frame 2
page
frame 3
…
page
frame Y
page
master
physical address frame 0
page table
page frame # offset page
secondary frame 1
secondary page table # page
page table # addr
frame 2
page
frame 3
page frame
…
number
page
frame Y
Memory
Memory
Memory Bridge Graphics
• Memory-mapped files
– Instead of standard system calls (read(), write(),
etc.) map file starting at virtual address X
• I.e., use the file for swap space for that part of VM
– Access to “X + n” refers to file at offset n
– All mapped file PTEs marked at start as invalid
– OS reads from file on first access
– OS writes to file when page is dirty and page is
evicted
CS502 Spring 2006 Paging 28
Paging – Summary
• Partition virtual memory into equal size units
called pages
• Any page can fit into any frame in physical
memory
• No relocation needed by loader
• Only active pages in memory at any time
• Supports very large virtual memories and
segmentation
• Hardware assistance is essential
• First introduction to the fundamental principle of
caching
CS502 Spring 2006 Paging 29
Caching
• Transaction processing
• Keep records of today’s departures in RAM while
records of future flights are on disk
• Program execution
• Keep the bytes near the current program counter in
on-chip memory while rest of program is in RAM
• File management
• Keep disk maps of open files in RAM while
retaining maps of all files on disk
• …
CS502 Spring 2006 Paging 31
Caching issues
• When to put something in the cache
• What to throw out to create cache space for new
items
• How to keep cached item and stored item in sync
after one or the other is updated
• How to keep multiple caches in sync across
processors or machines
• Size of cache needed to be effective
• Size of cache items for efficiency
• …
CS502 Spring 2006 Paging 32