Virtual Memory: Module - 3
Virtual Memory: Module - 3
Module – 3
1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
12/07/21 Copyright © 2009 www.egtoget.com 6
First-In-First-Out (FIFO) Algorithm
Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
3 frames (3 pages can be in memory at a time per
process)
1 1 4 5
2 2 1 3 9 page faults
3 3 2 4
4 frames
1 1 5 4
2 2 1 5 10 page faults
3 3 2
4 4 3
1) Counters:
2) Stack:
12/07/21 Copyright © 2009 www.egtoget.com 18
LRU Page Replacement
1) Counters:
We associate with each page-table entry a time-
of-use field, and add to the CPU a logical clock
or counter.
The clock is incremented for every memory
reference.
When a reference to a page is made, the contents
of the clock register are copied to the time-of-
use field in the page-table entry for that page.
12/07/21 Copyright © 2009 www.egtoget.com 19
LRU Page Replacement
In this way, we always have the “time” of the
last reference to each page.
The reference bit for a page is set, by the hardware whenever the
page is referenced.
As the user process executes, the bit associated with each page
referenced is set (to 1) by the hardware.
After some time we can determine which page have been used and
which not by examining the reference bits.
12/07/21 Copyright © 2009 www.egtoget.com 23
Global vs. Local Allocation
Global replacement:
Process selects a replacement frame from the set of all frames;
even if that frame is currently allocated to some other process;
One process can take a frame from another
Local replacement:
Each process selects from only its own set of allocated frames.
Ex: consider an allocation scheme where we allow high-priority
processes to select frames from low-priority processes for
replacement.
These processes need those pages, however, and so they also fault,
taking frames from other processes.