Download presentation
Presentation is loading. Please wait.
1
Day 23 Virtual Memory
2
Page buffering A page that is to be replaced remains in memory for some more time Will not require a disk access if it is needed in the immediate future. Alleviates the problem of an inaccurate page replacement decision A list of modified pages is maintained, so when writing back to disk, can write all the modified pages together. Used along with a simple page replacement scheme such as FIFO.
3
Page buffering A few frames are not allotted to any process.
When a page is to be replaced, its page table entry is added to one of two lists: Free page list, if page not modified Modified page list, if page modified When a new page is brought in, it is placed in the frame vacated by the page whose page table entry is in the front of the free page/modified page list, and the page table entry of the page to be replaced is placed at the end of the free page/modified page list.
4
1 34 2 56 3 4 .. 10 41 Main memory Modified frames list
Page 1 34 2 56 3 4 .. 10 41 Modified frames list Free frames list frame#, page # Head 0, 1 6, 5 7,35 Tail 30,38 frame#, page # Head 3, 4 9, 25 10,41 Tail 11,39 Page to be replaced is page 56 in frame 2, with new page 28 from disk. Page 56 has been modified.
5
1 34 2 56 3 28 .. 10 41 Main memory Modified frames list
Page 1 34 2 56 3 28 .. 10 41 Modified frames list Free frames list frame#, page # Head 9, 25 10,41 11,39 Tail 2,56 frame#, page # Head 0, 1 6, 5 7,35 Tail 30,38 Page to be replaced is page 34 (not modified), with page 41 (already in memory).
6
1 34 2 56 3 28 .. 10 41 Main memory Modified frames list
page # Head 9, 25 11,39 Tail 2,56 Frame # Page 1 34 2 56 3 28 .. 10 41 Free frames list frame#, page # Head 0, 1 6, 5 7,35 30,38 Tail 1,34 If page 28 in frame 3(not been modified) has to be replaced, and page 34 has to be placed in main memory, how will the lists and main memory change?
7
Resident Set Management
Resident set size - How many pages per process in main memory Replacement scope - 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
8
Resident set size Fixed-allocation – fixed number of frames in main memory for a process. Number decided at creation time Page to be replaced must be from the same process. Variable-allocation – number of pages allocated can change during the duration of the process. If there are many page faults, then increase the number of frames allocated and vice versa. OS has to observe program behavior and predict future behavior.
9
Replacement scope Global – consider all unlocked frames in main memory as candidates for replacement. Simpler to implement and more commonly used. Local – consider only frames allocated to the process that caused the page fault as candidates for replacement.
10
Resident set size and replacement scope
Fixed allocation, local scope Variable allocation, global scope Easiest to implement and commonly used. Page that is being replaced can be from any process But the process whose resident set size decreases may not be optimum Use page buffering to alleviate the problem.
11
Variable allocation, local scope
When a process is brought into main memory, assign a certain number of frames to the process. When a process page faults frequently, increase its resident set size. Periodically, re-evaluate the allocations to various processes and change resident set sizes.
12
Cleaning policy When should a modified page be written back to disk.
Demand cleaning – write back when a page has to be replaced. Process that suffers a page fault must wait for two disk accesses before it can be unblocked => processor under-utilized. Precleaning – write pages in batches a page may be written to disk many times before it is actually replaced
13
Load control Number of processes resident in main memory
Too few resident processes could result in processor being idle. Too many resident processes could result in frequent page faults and thrashing.
14
Load control/Multi-programming level strategies
Allow only processes whose resident set is sufficiently large. L (interpage fault lifetime) = S (page swap time) criterion Adjust the multi-programming level such that the mean time between page faults equals the mean time required to process a page fault. This is when processor utilization is maximum. If it takes 200ms to service a page fault, then if a page fault occurs every 200ms, then when P1 gets blocked, P2’s page would have just been brought to memory and it will be ready to run.
15
Load control/Multi-programming level strategies
50% criterion – keep utilization of the paging device at 50%. Adapt the clock page replacement algorithm Monitor the rate at which the pointer scans the circular buffer of frames. If the rate is below a threshold: Few page faults => few requests to advance the pointer. For each request, the number of pages being scanned is small => many pages in the resident set are not being accessed frequently and need not be present. In either case, can decrease the resident set size and increase the multi-programming level.
16
Process to be suspended to reduce the multi-programming level
Lowest-priority process Faulting process – is going to be blocked anyway. Last process activated – least likely to have its resident set. Process with smallest resident set – least future effort to reload. Largest process – releases more frames. Process with largest remaining execution time window – allows processes that are closer to finishing to continue.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.