際際滷

際際滷Share a Scribd company logo
Pagereplacement algorithm(computional concept)
Overview
1. Why we need page replacement?
2. Basic page replacement technique.
3. Different type of page replacement algorithm and
their examples.
Why????
Limited physical memory --> limited number of
frame --> limited number of frame allocated to a
process.
Basic Page Replacement
1. Find the location of the desired page on the
disk.
2. Find a free frame
 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.
Basic Page Replacement (Contd)
3. Read the desired page into the newly freed frame,
change the page and frame tables.
4. Restart the user process.
Page Replacement
Victim
Swap desire
page in
Reset page
table for new
page
Change to
invaid
Page table
Frame
Valid
invalid bit
2
4
3
0
F
I
V
Swap out
victim page
1
Physical memory
Overhead
If no free frames - 2 page transfers.
Solution : Modify bit or Dirty bit.
Replacement Policy
Which page to be replaced?
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.
Page faults versus number of frames
Number of frames
Number of page
faults
Replacement Algorithm
1. FIFO page replacement
2. Optimal page replacement
3. LRU page replacement
FIFO Page Replacement
Easy to understand and program.
Performance is not always good.
Beladys Anomaly
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 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
7
0
7 7
0
1
2
0
1
2
3
1
2
3
0
4
3
0
4
2
0
4
2
3
0
2
3
0
1
3
0
1
2
7
1
2
7
0
2
7
0
1
Optimal Page Replacement
Lowest page fault rate of all algorithms
Free from Beladys anomaly
Optimal Page Replacement (contd)
Replace the page that will not be used for the longest
period of time.
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 2 1 2 0 1 7 0 1
7
0
7 7
0
1
2
0
1
2
0
3
2
4
3
2
0
3
7
0
1
2
0
1
LRU Page Replacement
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 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
7
0
7 7
0
1
2
0
1
2
0
3
4
3
4
2
3
2
0
3
7
0
1
0
4
2
0
2
3
1
2
0
1
Ans: C
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
Reference String
4. The string of memory references is called
___________.
Beladys Anomaly
5. FIFO page replacement suffers from
________________anomaly.
Page fault increases with increase in number of
frames.
6. What is Beladys anomaly??
TRUE
7. Optimal Page Replacement algorithm has the
lowest page fault rate.
TRUE/FALSE

More Related Content

Pagereplacement algorithm(computional concept)

  • 2. Overview 1. Why we need page replacement? 2. Basic page replacement technique. 3. Different type of page replacement algorithm and their examples.
  • 3. Why???? Limited physical memory --> limited number of frame --> limited number of frame allocated to a process.
  • 4. Basic Page Replacement 1. Find the location of the desired page on the disk. 2. Find a free frame 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.
  • 5. Basic Page Replacement (Contd) 3. Read the desired page into the newly freed frame, change the page and frame tables. 4. Restart the user process.
  • 6. Page Replacement Victim Swap desire page in Reset page table for new page Change to invaid Page table Frame Valid invalid bit 2 4 3 0 F I V Swap out victim page 1 Physical memory
  • 7. Overhead If no free frames - 2 page transfers. Solution : Modify bit or Dirty bit.
  • 8. Replacement Policy Which page to be replaced? 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.
  • 9. Page faults versus number of frames Number of frames Number of page faults
  • 10. Replacement Algorithm 1. FIFO page replacement 2. Optimal page replacement 3. LRU page replacement
  • 11. FIFO Page Replacement Easy to understand and program. Performance is not always good. Beladys Anomaly
  • 12. 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.
  • 13. FIFO An Example 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1 7 0 7 7 0 1 2 0 1 2 3 1 2 3 0 4 3 0 4 2 0 4 2 3 0 2 3 0 1 3 0 1 2 7 1 2 7 0 2 7 0 1
  • 14. Optimal Page Replacement Lowest page fault rate of all algorithms Free from Beladys anomaly
  • 15. Optimal Page Replacement (contd) Replace the page that will not be used for the longest period of time. Requires future knowledge of the reference string. Used for comparison studies.
  • 16. OPR An Example 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1 7 0 7 7 0 1 2 0 1 2 0 3 2 4 3 2 0 3 7 0 1 2 0 1
  • 17. LRU Page Replacement Free from Beladys Anomaly. Problem: How to order the frame defined by the time of last use. Solution: Counters Queue
  • 18. LRU An Example 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1 7 0 7 7 0 1 2 0 1 2 0 3 4 3 4 2 3 2 0 3 7 0 1 0 4 2 0 2 3 1 2 0 1
  • 19. Ans: C 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.
  • 20. 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
  • 21. Reference String 4. The string of memory references is called ___________.
  • 22. Beladys Anomaly 5. FIFO page replacement suffers from ________________anomaly.
  • 23. Page fault increases with increase in number of frames. 6. What is Beladys anomaly??
  • 24. TRUE 7. Optimal Page Replacement algorithm has the lowest page fault rate. TRUE/FALSE