virtual memory n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Virtual Memory PowerPoint Presentation
Download Presentation
Virtual Memory

Loading in 2 Seconds...

play fullscreen
1 / 15

Virtual Memory - PowerPoint PPT Presentation


  • 105 Views
  • Uploaded on

Virtual Memory. CSE451 Andrew Whitaker. Review: Address Translation. virtual address. virtual page #. offset. physical memory. page frame 0. page table. page frame 1. physical address. page frame 2. page frame #. page frame #. offset. page frame 3. ….

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Virtual Memory' - allan


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
virtual memory

Virtual Memory

CSE451

Andrew Whitaker

review address translation
Review: Address Translation

virtual address

virtual page #

offset

physical memory

page

frame 0

page table

page

frame 1

physical address

page

frame 2

page frame #

page frame #

offset

page

frame 3

Note: Each process has its own page table!

page

frame Y

problem physical memory scarcity
Problem: Physical Memory Scarcity
  • Q: Which is bigger:
    • A 64 bit address space
    • Or, the number of hydrogen molecules in a star?
  • A: It’s the star
    • 2^64 bytes in an address space
    • 10^57 hydrogen atoms in a star
    • 57 * log 10 > 64 * log 2
  • But, the fact we have to ask is significant!
solution virtual memory
Solution: Virtual Memory
  • Physical memory stores a subset of virtual address space
    • The rest is stored on disk
    • Main memory acts as a page cache
  • Implemented transparently by the OS and hardware
    • Application can’t tell which pages are in memory

virtual

memory

physical

memory

how does virtual memory work
How Does Virtual Memory Work?
  • Page table entry contains a valid bit
    • Says whether the mapping is valid
  • If valid bit is not set, the system raises a page fault
    • Behaves like an (involuntary) system call

1

1

1

2

20

V

R

M

prot

page frame number

what happens on a page fault
What Happens on a Page Fault?
  • Hardware raises an exception
  • OS page fault handler runs
    • First, make sure the address is valid
      • If not, raise a segmentation fault
    • Second, verify access type
      • Not allowed to write to a read-only page!
  • If access is legal, allocate a new page frame
    • What happens if physical memory is scarce… stay tuned!
  • OS reads page frame from disk
    • Process/thread is blocked during this process
  • Once read completes, OS updates the PTE and resumes the process/thread
demand paging
Demand Paging
  • What happens when a process first starts?
  • Two choices:
    • Eagerly bring in pages
    • Lazily fault in pages
      • Called demand paging
  • Most OS’s prefer demand paging
    • Doesn’t require guessing, maintaining history
  • Slightly smarter approach: clustering
    • Bring in the faulting page and several subsequent pages
      • This is used by Windows XP
dealing with memory scarcity
Dealing With Memory Scarcity
  • Physical memory is over-allocated
    • We can run out!
  • OS needs a page replacement strategy
  • Before diving into particular strategies, lets look at some theory…
locality of reference
Locality of Reference
  • Programs tend to reuse data and instructions they have used recently
  • These “hot” items are a small fraction of total memory
    • Rule of thumb: 90% of execution time is spent in 10% of the code
  • This is what makes caching work!
the working set model
The Working Set Model
  • The working set represents those pages currently in use by a program
  • The working set contents change over time
    • So does the size of the working set
  • To get reasonable performance, a program must be allocated enough pages for its working set
slide11

working

set

A hypothetical web server

This is a bimodal distribution

Request / second of throughput

Number of page frames allocated to process

thrashing
Thrashing
  • Programs with an allocation beneath their working set will thrash
    • Each page fault evicts a “hot” page
    • That page will be needed soon…
    • Evicted page takes a page fault
    • [repeat]
  • Net result: no work gets done
    • All time is devoted to paging operations
over allocation
Over-allocation
  • Giving a program more than its working set does very little good
  • Page eviction strategies take advantage of this
generalizing to multiple processes
Generalizing to Multiple Processes
  • Let W to be the sum of working sets for all active processes
  • Let M be amount of physical memory
  • If W > M, the system as a whole will thrash
    • No page replacement policy will work :-(
  • If W <= M, the system might perform well
    • Key issue: is the page replacement policy smart enough to identify working sets?
which of these eviction strategies is good at capturing working sets
Which of These Eviction Strategies is Good at Capturing Working Sets?
  • Random page eviction
  • FIFO page eviction
  • Least-recently used page eviction