Professional Documents
Culture Documents
Page Replacement: Sashikanta Taorem
Page Replacement: Sashikanta Taorem
Page Replacement: Sashikanta Taorem
Presented by:
Sashikanta Taorem
MTech CSE 1st Semester
Overview
1.
2.
3.
Why????
Limited physical memory --> limited number of frame --> limited number of frame allocated to a process.
Find the location of the desired page on the disk. Find a free frame
2.
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.
Page Replacement
Valid invalid bit Change to invaid Victim
4
Frame
0 F
I V
Page table
Physical memory
Overhead
Replacement Policy
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.
Number of frames
Replacement Algorithm
1.
2.
3.
4.
5.
Drawbacks - FIFO
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.
FIFO An Example
7 0 1 7 7 7 0 0 1 2 0 3 0 4 2 2 2 4 0 3 3 3 1 1 0 0 2 4 2 0 3 4 2 3 0 3 2 1 2 0 1 7 0 1 0 0 0 7 7 7 2 1 1 1 0 0 3 3 2 2 2 1
Requires future knowledge of the reference string. Used for comparison studies.
OPR An Example
7 0 1 2 0 3 0 4 2 3 0 3 7 7 7 2 2 2 2 0 0 0 0 4 0 1 1 3 3 3
2 1 2 0 1 7 0 1 2 7 0 0 1 1
Free from Beladys Anomaly. Problem: How to order the frame defined by the time of last use. Solution:
Counters Queue
LRU An Example
7 0 1 7 7 7 0 0 1
2 0 3 0 4 2 3 2 2 4 4 4 0 0 0 0 3 1 3 3 2 2
0 3 2 1 2 0 1 7 0 1 0 1 1 1 3 3 0 0 2 2 2 7
Additional-Reference-Bits Algorithm
Second-Chance Algorithm
Enhanced Second-Chance Algorithm
Additional-Reference-Bits Algorithm
Shift the reference bit into the high-order bit of 8-bit byte, shifting the other bits right by 1 bit and discarding the loworder bit.
Additional-Reference-Bits Algorithm
Example:
00000000 page has not been use for eight time period. 11111111 use at least once in each time period.
Second-Chance Algorithm
Considers the Reference bit and the modify bit as an ordered pair, (Reference bit, Modify bit). Four possible cases:
1. 2. 3. 4.
Uses COUNTERS to count the number of references that have been made to each page. Least Frequently used Most frequently Used
1. 2.
Page-Buffering algorithm
Uses POOL of frames When a page fault occurs, a victim is chosen but the page is read into a free frame from the pool before the victim is written out.
When a page fault occurs, we first check whether the desire page is in the free-frame pool. If it is not, we must select a free frame and read into it.
Objective Questions!!!
1.
Dirty bit is used to show the a. page with corrupted data b. the wrong page in the memory c. page that is modified after being loaded into cache memory d. page that is less frequently accessed.
Ans: C
2. What replacement policy is used by Windows NT a. LRU b. NFU c. FIFO d. Clock Replacement e. None of the above
Ans: C
CLOCK algorithm
Reference String
Beladys Anomaly
7. Optimal Page Replacement algorithm has the lowest page fault rate. TRUE/FALSE
TRUE