1 / 13

Page Replacement

Page Replacement. Overview. Why we need page replacement? Basic page replacement technique. Different type of page replacement algorithm and their examples. Why????. Limited physical memory --> limited number of frame --> limited number of frame allocated to a process.

floyd
Télécharger la présentation

Page Replacement

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Page Replacement

  2. Overview • Why we need page replacement? • Basic page replacement technique. • Different type of page replacement algorithm and their examples.

  3. Why???? • Limited physical memory --> limited number of frame --> limited number of frame allocated to a process.

  4. Basic Page Replacement • Find the location of the desired page on the disk. • Find a free frame • If there is a free frame use it. • No free frame – use page replacement algorithm to select a victim frame. • Write the victim frame to disk, change the frame and page tables accordingly.

  5. Replacement Policy • Which page to be replaced? • Page removed should be the page least likely to be referenced in the near future. • Most policies predict the future behavior on the basis of past behavior.

  6. Replacement Algorithm • FIFO page replacement • Optimal page replacement • LRU page replacement • LRU-Approximation page replacement • Counting-Based page replacement

  7. example String Reference 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1 0 0 3 2 0 2 7 7 7 7 0 2 1 0 2 7 0 3 7 4 0 3 1 0 3 2 1 1 3 1 7 3 4 3 7 7 1 0 1 Young page Frames initially empty 2 2 2 3 7 2 0 7 2 2 0 0 1 0 4 7 2 0 Old Page * * * * * * * * * * * * Page faults

  8. FIFO Page Replacement • FIFO is similar to First In First Out CPU scheduling algorithm wherein the requested page is loaded first and subsequent fetches are also serviced in order of request arrival. • A page which is being accessed quite often may also get replaced because it arrived earlier than those present • Ignores locality of reference. A page which was referenced last may also get replaced, although there is high probability that the same page may be needed again.

  9. FIFO pf/n pf = page faults N = number of reference made 12/20 = 60% 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1 2 2 1 4 0 3 0 2 7 7 7 7 7 3 0 7 0 0 2 0 7 4 3 1 3 1 1 3 7 2 0 3 0 1 7 1 0 3 1 7 0 7 2 1 4 2 2 2 0 3 2 2 0 0 2 0 7 * * * * * * * * * * * *

  10. Optimal Page Replacement (OPT) • The main idea of OPT is to replace the pages found n the frames that re not going to be used/ referenced soon. • An optimal page-replacement algorithm has the lowest page-fault rate of all algorithms (called OPT or MIN). It is simply this: Replace the page that will not be used for the longest period of time. - At the moment of page fault: • Label each page in memory is labeled with the number of instructions that will be executed before that page is first referenced • Replace the page with the highest number: i.e. postpone as much as possible the next page fault

  11. OPT pf/n pf = page faults N = number of reference made 6/20 = 30% 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1 4 0 4 7 0 0 0 0 0 0 7 2 0 0 0 7 0 0 4 2 1 2 1 0 0 1 2 1 1 2 2 2 2 1 0 2 3 1 1 7 1 3 2 3 7 3 3 1 3 7 2 0 3 0 2 2 3 * * * * * *

  12. Least Recently Used Page Replacement Algorithm • This algorithm reposes on the opposite of the concept of temporal locality, wherein if a page has not been referenced for quite some time then it is not going to be referenced in the future.

  13. Least Recently Used Page Replacement Algorithm • Pf/N 9 / 20 = 45% 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1 2 2 4 3 2 1 0 0 7 7 1 7 2 3 2 7 2 1 3 0 3 0 2 2 3 1 7 4 7 0 3 3 0 2 0 0 0 1 2 0 0 2 1 3 4 0 1 1 2 2 1 2 0 1 0 3 0 * * * * * * * * *

More Related