Chapter 9 virtual memory
Download
1 / 18

Chapter 9: Virtual Memory - PowerPoint PPT Presentation


  • 79 Views
  • Uploaded on

Chapter 9: Virtual Memory. Adapted by Donghui Zhang from the original version by Silberschatz et al. Chapter 9: Virtual Memory. Why VM Demand Paging Page Fault Copy-on-Write Page Replacement. Why VM?. Only part of the program needs to be in memory for execution

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 ' Chapter 9: Virtual Memory' - taite


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
Chapter 9 virtual memory

Chapter 9: Virtual Memory

Adapted by Donghui Zhang from the original version by Silberschatz et al.


Chapter 9 virtual memory1
Chapter 9: Virtual Memory

  • Why VM

  • Demand Paging

  • Page Fault

  • Copy-on-Write

  • Page Replacement


Why vm
Why VM?

  • Only part of the program needs to be in memory for execution

  • Logical address space can therefore be much larger than physical address space

  • Allows for more efficient process creation



Demand paging
Demand Paging

  • Bring a page into memory only when it is needed

    • Less I/O needed

    • Less memory needed

    • Faster response

    • More users

  • Page is needed  reference to it

    • invalid reference  abort

    • not-in-memory  bring to memory


Valid invalid bit
Valid-Invalid Bit

  • With each page table entry a valid–invalid bit is associated(v in-memory,i  not-in-memory)

  • Initially valid–invalid bit is set to i on all entries

  • Example of a page table snapshot:

  • During address translation, if valid–invalid bit in page table entry

    is I  page fault

Frame #

valid-invalid bit

v

v

v

v

i

….

i

i

page table



Page fault
Page Fault

  • If there is a reference to a page, first reference to that page will trap to operating system:

    page fault

  • Operating system looks at another table to decide:

    • Invalid reference  abort

    • Just not in memory

  • Get empty frame

  • Swap page into frame

  • Reset tables

  • Set validation bit = v

  • Restart the instruction that caused the page fault



Performance of demand paging

page fault service time

Performance of Demand Paging

  • Page Fault Rate 0  p  1.0

    • if p = 0 no page faults

    • if p = 1, every reference is a fault

  • Effective Access Time (EAT)

    EAT = (1 – p) x memory access

    + p x ( page fault overhead

    + swap page out

    + swap page in

    + restart overhead )


Demand paging example
Demand Paging Example

  • Memory access time = 200 nanoseconds

  • Average page-fault service time = 8 milliseconds

  • EAT = (1 – p) x 200 + p x (8 milliseconds)

    = (1 – p) x 200 + p x 8,000,000

    = 200 + p x 7,999,800

  • If one access out of 1,000 causes a page fault, then

    EAT = 8.2 microseconds.

    This is a slowdown by a factor of 40!!

1 s = 1000 milli s

1 milli s = 1000 micro s

1 micro s = 1000 nano s


Copy on write
Copy-on-Write

  • Copy-on-Write (COW) allows both parent and child processes to initially share the same pages in memoryIf either process modifies a shared page, only then is the page copied

  • COW allows more efficient process creation as only modified pages are copied


Before process 1 modifies page c
Before Process 1 Modifies Page C

After the modification, a new copy of Page C is generated for process 1.


What happens if there is no free frame
What happens if there is no free frame?

  • Page replacement – find some page in memory, but not really in use, swap it out!

  • Which one?

    • FIFO/LIFO

    • LRU/MRU

    • LFU/MFU

  • Side note: should keep a dirty bit for each frame.


Basic page replacement
Basic Page Replacement

  • Find the location of the desired page on disk

  • Find a free frame: - If there is a free frame, use it - If there is no free frame, use a page replacement algorithm to select a victim frame

  • Bring the desired page into the (newly) free frame; update the page and frame tables

  • Restart the process


Page replacement algorithms
Page Replacement Algorithms

  • Want lowest page-fault rate

  • Evaluate algorithm by running it on a particular string of memory references (reference string) and computing the number of page faults on that string

  • In all our examples, the reference string is

    1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5


Page replacement algorithms1
Page Replacement Algorithms

  • FIFO – First In First Out

  • LRU – Least Recently Used

  • LFU – Least Frequently Used

  • LIFO – Last In First Out

  • MRU – Most Recently Used

  • MFU – Most Frequently Used

    1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5



ad