1 / 15

Scribe for 7 th April 2014

Scribe for 7 th April 2014. Page Replacement Algorithms Payal Priyadarshini 11CS30023. Page replacement.

ludwig
Download Presentation

Scribe for 7 th April 2014

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. Scribe for7thApril 2014 Page Replacement Algorithms Payal Priyadarshini 11CS30023

  2. Page replacement • In case of page fault, if all the frames are full then we have to replace/swap out the pages of same process as victim. We should not make pages of another process as victim as it will lead to thrashing. EAT = (1-p) * memory access + p (page fault overhead + swap page out+ swap page in + restart)

  3. Page Replacement

  4. Steps to follow in Page Replacement • Choose the victim page from main memory(frame f) of same process. Swap that page out in the swap space. Write back into disk, if the dirty bit is 1. Otherwise don’t need to write back. • Change the page table entry corresponding to particular page from valid(v) to invalid(i). • Swap in the required/demanded page into the main memory. • Update the page table entry corresponding to swapped in page to frame f and set valid/invalid bit to v.

  5. Page Replacement

  6. Improving the swap in/out • If we have modified that page which we have choose as victim frame. Check dirty bit ( modification leads to 1 ) if it is 1 then, write into the disk otherwise not.

  7. Evaluation : Page Replacement Algorithms • Evaluate algorithm by running it on a particular string of memory references (reference string) and computing the number of page faults on that string • String is just page numbers, not full addresses Repeated access to the same page does not cause a page fault • Trace memory references of a process. Sniffer: It will store all the physical addresses generated by CPU. • How to evaluate Victim page ?

  8. Evaluation (cont’d) : • Reference string of memory accesses : 0100, 0432, 0101, 0612, 0102, 0104, 0101, 0611, 0102 three consecutive access of same page which will lead to only 1 page faults Page size : 100B Reference string 1, 4, 1, 6, 1, 6

  9. Graph of Page Faults Versus The Number of Frames This graph show as we increase the number of frames page fault rate will decrease, which is not always the case with some page replacement algorithms.

  10. First-In-First-Out (FIFO) Algorithm • When any frames arrives in the main memory along with that store the corresponding Time-Stamp. Now, select the victim page with the least value of time-stamp. • Methods to find out oldest page: - Associates a time with each frame when the page was brought into memory We can maintain a FIFO queue instead of maintaining actual Time-stamp.

  11. FIFO Page Replacement 15 page faults. 3 frames in main memory. How to track ages of pages? • Use a FIFO queue to maintain pages in main memory. • Replace the page at the head. • Inset at tail.

  12. Optimal Page Replacement • Replace the pages which we don’t require recently. • Replace the page that will not be required for longest period of time. 09 page faults. Although we can not predict future, But this algorithm can be the page mark for other algorithm.

  13. Least Recently Used (LRU) Algorithm • Use past knowledge rather than future. • Past is the proxy for future. • Replace the pages that has not been been used in most of the time. • Associate time of last use with each page. 12 page faults.

  14. LRU - Implementation • Counter implementation • CPU maintains a clock • Every page entry has a Time of use; • every time page is referenced, copy the clock into the time of use • When a page needs to be replaced, look at the “Time of use” to find smallest value • Search through table needed

  15. Stack Implementation • Stack implementation • Keep a stack of page numbers in a double linked list form: • Page referenced: • move it to the top • When page needed to be replaced(victim), remove page from bottom.

More Related