virtual memory names virtual addresses physical addresses
play

Virtual Memory Names, Virtual Addresses & Physical Addresses - PowerPoint PPT Presentation

Virtual Memory Names, Virtual Addresses & Physical Addresses Source Absolute Program Module Name Space Name Space Virtual Virtual Address Space Address Space Compile/Link tools Names, Virtual Addresses & Physical Addresses


  1. Virtual Memory

  2. Names, Virtual Addresses & Physical Addresses Source Absolute Program Module Name Space Name Space Virtual Virtual Address Space Address Space Compile/Link tools

  3. Names, Virtual Addresses & Physical Addresses Source Absolute Executable Program Module Image Name Space Name Space Virtual Virtual Address Space Address Space Physical Physical Address Space Address Space ? t : Virtual Address Space ? Physical Address Space

  4. Virtual Memory • Uses dynamic address relocation/binding – Generalization of base-limit registers – Physical address corresponding to a compile- time address is not known until run time • Idea is that only part of the address space is loaded as process executes • This works because of program and data locality

  5. Virtual Memory (cont) • Use a dynamic virtual address map, ? t Virtual Physical ? t Address Address Space Space

  6. Address Formation • Translation system produces an address space, but address are virtual instead of physical • A virtual address, x: – Is mapped to y = ? t (x) if x is loaded at physical address y – Is mapped to ? if x is not loaded • The map changes as the program executes ? t : Virtual Address ? Physical Address ? { ? } •

  7. Size of Blocks of Memory • Fixed size: Pages are moved back and forth between primary and secondary memory • Variable size: Programmer-defined segments are the unit of movement • Paging is the commercially dominant form of virtual memory today

  8. Paging • A page is a fixed sized block of virtual addresses • A page frame is a fixed size block of physical memory, the same size as a page • When a virtual address in page i is referenced by the CPU – If page i is loaded at page frame j, the virtual address is relocated to page frame j – If page is not loaded, the OS interrupts the process and loads the page into a page frame

  9. Addresses • Suppose there are G=2 g+h virtual addresses and H=2 j+h physical addresses – Each page/page frame is 2 h addresses – There are 2 g pages in the virtual address space – 2 j page frames are allocated to the process – Rather than map individual addresses, ? t maps the 2 g pages to the 2 j page frames

  10. Address Translation • Let N = {d 0 , d 1 , … d n-1 } be the pages • Let M = {b 0 , b 1 , …, b m-1 } be page frames • Virtual address, i, satisfies 0 ? i<G= 2 g+h • Physical address, k = U2 h +V (0 ? V<G= 2 h ) – U is page frame number – V is the line number within the page – ? t :[0:G-1] ? <U, V> ? { ? } – Since every page is size c=2 h • page number = U = ? i/c ? • line number = V = i mod c

  11. Address Translation (cont) g bits h bits Page # Line # Virtual Address ? t Missing Page j bits h bits Physical Address Frame # Line # CPU Memory MAR

  12. Demand Paging • Page fault occurs • Process with missing page is interrupted • Memory manager locates the missing page • Page frame is unloaded (replacement policy) • Page is loaded in the vacated page frame • Page table is updated • Process is restarted

  13. Modeling Page Behavior • Let ? = r 1 , r 2 , r 3 , …, r i , … be a page reference stream – r i is the i th page # referenced by the process – The subscript is the virtual time for the process • Given a page frame allocation of m, the memory state at time t, S t (m), is set of pages loaded – S t (m) = S t-1 (m) ? X t - Y t • X t is the set of fetched pages at time t • Y t is the set of replaced pages at time t

  14. More on Demand Paging • If r t was loaded at time t-1, S t (m) = S t-1 (m) • If r t was not loaded at time t-1 and there were empty page frames – S t (m) = S t-1 (m) ? {r t } • If r t was not loaded at time t-1 and there were no empty page frames – S t (m) = S t-1 (m) ? {r t } - {y} • The alternative is prefetch paging

  15. Static Allocation, Demand Paging • Number of page frames is static over the life of the process • Fetch policy is demand • Since S t (m) = S t-1 (m) ? {r t } - {y}, the replacement policy must choose y -- which uniquely identifies the paging policy

  16. Random Replacement • Replaced page, y, is chosen from the m loaded page frames with probability 1/m Let page reference stream, ? = 2031203120316457 Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 1 2

  17. Random Replacement • Replaced page, y, is chosen from the m loaded page frames with probability 1/m Let page reference stream, ? = 2031203120316457 Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 1 0 0 2 3

  18. Random Replacement • Replaced page, y, is chosen from the m loaded page frames with probability 1/m Let page reference stream, ? = 2031203120316457 Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 1 0 0 1 2 3 3

  19. Random Replacement • Replaced page, y, is chosen from the m loaded page frames with probability 1/m Let page reference stream, ? = 2031203120316457 Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 2 2 1 0 0 1 1 1 2 3 3 3 0

  20. Random Replacement • Replaced page, y, is chosen from the m loaded page frames with probability 1/m Let page reference stream, ? = 2031203120316457 Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 2 2 3 1 0 0 1 1 1 1 2 3 3 3 0 0

  21. Random Replacement • Replaced page, y, is chosen from the m loaded page frames with probability 1/m Let page reference stream, ? = 2031203120316457 Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 2 2 3 3 3 1 0 0 1 1 1 1 1 1 2 3 3 3 0 0 0 2

  22. Random Replacement • Replaced page, y, is chosen from the m loaded page frames with probability 1/m Let page reference stream, ? = 2031203120316457 Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 2 2 3 3 3 0 1 0 0 1 1 1 1 1 1 1 2 3 3 3 0 0 0 2 2

  23. Random Replacement • Replaced page, y, is chosen from the m loaded page frames with probability 1/m Let page reference stream, ? = 2031203120316457 Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 2 2 3 3 3 0 0 1 0 0 1 1 1 1 1 1 1 3 2 3 3 3 0 0 0 2 2 2

  24. Random Replacement • Replaced page, y, is chosen from the m loaded page frames with probability 1/m Let page reference stream, ? = 2031203120316457 Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 2 2 3 3 3 0 0 0 0 1 0 0 1 1 1 1 1 1 1 3 3 6 2 3 3 3 0 0 0 2 2 2 1 1

  25. Random Replacement • Replaced page, y, is chosen from the m loaded page frames with probability 1/m Let page reference stream, ? = 2031203120316457 Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 2 2 3 3 3 0 0 0 0 4 1 0 0 1 1 1 1 1 1 1 3 3 6 6 2 3 3 3 0 0 0 2 2 2 1 1 1

  26. Random Replacement • Replaced page, y, is chosen from the m loaded page frames with probability 1/m Let page reference stream, ? = 2031203120316457 Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 2 2 3 3 3 0 0 0 0 4 4 1 0 0 1 1 1 1 1 1 1 3 3 6 6 5 2 3 3 3 0 0 0 2 2 2 1 1 1 1

  27. Random Replacement • Replaced page, y, is chosen from the m loaded page frames with probability 1/m Let page reference stream, ? = 2031203120316457 Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 2 2 3 3 3 0 0 0 0 4 4 7 1 0 0 1 1 1 1 1 1 1 3 3 6 6 5 5 2 3 3 3 0 0 0 2 2 2 1 1 1 1 1

  28. Random Replacement • Replaced page, y, is chosen from the m loaded page frames with probability 1/m Let page reference stream, ? = 2031203120316457 Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 2 2 3 3 3 0 0 0 0 4 4 7 1 0 0 1 1 1 1 1 1 1 3 3 6 6 5 5 2 3 3 3 0 0 0 2 2 2 1 1 1 1 1 13 page faults • No knowledge of ? ? not perform well • Easy to implement

  29. Belady’s Optimal Algorithm • Replace page with maximal forward distance: y t = max xeS t-1(m) FWD t (x) Let page reference stream, ? = 2031203120316457 Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 1 0 0 2 3

  30. Belady’s Optimal Algorithm • Replace page with maximal forward distance: y t = max xeS t-1(m) FWD t (x) Let page reference stream, ? = 2031203120316457 Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 1 0 0 2 3 FWD 4 (2) = 1 FWD 4 (0) = 2 FWD 4 (3) = 3

  31. Belady’s Optimal Algorithm • Replace page with maximal forward distance: y t = max xeS t-1(m) FWD t (x) Let page reference stream, ? = 2031203120316457 Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 1 0 0 0 2 3 1 FWD 4 (2) = 1 FWD 4 (0) = 2 FWD 4 (3) = 3

  32. Belady’s Optimal Algorithm • Replace page with maximal forward distance: y t = max xeS t-1(m) FWD t (x) Let page reference stream, ? = 2031203120316457 Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 2 2 1 0 0 0 0 0 2 3 1 1 1

  33. Belady’s Optimal Algorithm • Replace page with maximal forward distance: y t = max xeS t-1(m) FWD t (x) Let page reference stream, ? = 2031203120316457 Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 2 2 2 1 0 0 0 0 0 3 2 3 1 1 1 1 FWD 7 (2) = 2 FWD 7 (0) = 3 FWD 7 (1) = 1

  34. Belady’s Optimal Algorithm • Replace page with maximal forward distance: y t = max xeS t-1(m) FWD t (x) Let page reference stream, ? = 2031203120316457 Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 2 2 2 2 2 0 1 0 0 0 0 0 3 3 3 3 2 3 1 1 1 1 1 1 1 FWD 10 (2) = ? FWD 10 (3) = 2 FWD 10 (1) = 3

  35. Belady’s Optimal Algorithm • Replace page with maximal forward distance: y t = max xeS t-1(m) FWD t (x) Let page reference stream, ? = 2031203120316457 Frame 2 0 3 1 2 0 3 1 2 0 3 1 6 4 5 7 0 2 2 2 2 2 2 2 2 2 0 0 0 1 0 0 0 0 0 3 3 3 3 3 3 2 3 1 1 1 1 1 1 1 1 1 FWD 13 (0) = ? FWD 13 (3) = ? FWD 13 (1) = ?

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend