Download presentation
Presentation is loading. Please wait.
1
Day 23 Virtual Memory
2
Operating system’s role in VM Hardware-support Use VM or not Use paging or segmentation or both Software domain Algorithms for memory management Aim is to minimize page faults No optimum strategy Depends on main memory size, # of processes, relative speed of main memory and secondary memory, size of processes and the behavior of individual processes.
3
Algorithms for: Fetch policy Placement Policy Replacement policy Resident Set Management Cleaning policy Load Control
4
Fetch policy When should a page be loaded in to memory Demand paging When a reference is made to a location in the page Pre-paging Load the page referenced as well as the “n” neighboring pages Exploits the characteristics of most secondary devices. If the pages of a process are stored in contiguous locations, then it may be effective.
5
Placement Where to place a portion. With segments, use best-fit, first-fit etc to minimize external fragmentation. With paging or paging combined with segmentation, this is not an issue. Any available frame can be used.
6
Which page to replace Resident set management How many pages per process in main memory When bringing in a new page, should the page being replaced be that of the process that caused the page fault or could it belong to any process Replacement policy Among the pages eligible to be replaced, which one should be replaced to keep the page faults at a minimum. Page to be replaced must be the one least likely to be replaced in the immediate future
7
Which page? Optimal – Page for which the time to the next reference is longest Impossible to implement as must know what will happen in the future. Least recently used – Page that has not been referenced in the longest time Difficulty in maintaining the information as to when each page was last referenced.
8
Which page? First-in-first-out Memory frames are treated as a circular buffer. Keeping a pointer to page that has been in memory the longest. Replace the page that has been in memory the longest and advance the pointer to the next frame.
11
Which page? – Clock policy Every frame has a use bit. It is set to 1, when the page is first brought in. The use bit is set to 1 every time the page is referenced. A pointer is used to point to the page after the one that was just replaced in the circular buffer(like in FIFO). When a page fault occurs: Start at pointer and scan the use bits of each frame. If use bit = 1, set to zero. If use bit = 0, then replace the frame. Update pointer to next frame. If all the frames have bit set to one, then pointer will go one complete circle and the first page will be replaced (FIFO) Otherwise, it is like LRU – replacing the page that has been least recently accessed.
13
Variant to the simple clock policy – make more powerful by increasing the # of bits. u (use bit), m (modify bit). Not accessed recently, not modified (u=0,m=0) Not accessed recently, modified (u=0,m=1) Accessed recently, not modified (u=1,m=0) Access recently, modified recently (u=1,m=1) Replace pages that have not been used recently else not modified.
14
Step 1: Starting at pointer, replace page that has u=0, m=0 Step 2: Starting at pointer, replace page that has u=0, m=1. Also, set all u=1 to u=0 Step 3: Repeat 1 and/or 2.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.