pagereplacement algorithm(computional concept)

24

Upload: siddhi-viradiya

Post on 18-Jul-2015

29 views

Category:

Engineering


1 download

TRANSCRIPT

Page 1: Pagereplacement algorithm(computional concept)
Page 2: Pagereplacement algorithm(computional concept)

Overview1. Why we need page replacement?

2. Basic page replacement technique.

3. Different type of page replacement algorithm and their examples.

Page 3: Pagereplacement algorithm(computional concept)

Why????Limited physical memory --> limited number of

frame --> limited number of frame allocated to a process.

Page 4: Pagereplacement algorithm(computional concept)

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.

Page 5: Pagereplacement algorithm(computional concept)

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 6: Pagereplacement algorithm(computional concept)

Page Replacement

Victim

Swap desirepage in

Reset pagetable for new page

Change toinvaid

Page table

FrameValid invalid bit

2

4

3

0F

I V

Swap outvictim page

1

Physical memory

Page 7: Pagereplacement algorithm(computional concept)

OverheadIf no free frames - 2 page transfers.

Solution : Modify bit or Dirty bit.

Page 8: Pagereplacement algorithm(computional concept)

Replacement PolicyWhich 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 9: Pagereplacement algorithm(computional concept)

Page faults versus number of frames

Number of frames

Number of page faults

Page 10: Pagereplacement algorithm(computional concept)

Replacement Algorithm

1. FIFO page replacement

2. Optimal page replacement

3. LRU page replacement

Page 11: Pagereplacement algorithm(computional concept)

FIFO Page ReplacementEasy to understand and program.

Performance is not always good.

Belady’s Anomaly

Page 12: Pagereplacement algorithm(computional concept)

Drawbacks - FIFOA 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.

Page 13: Pagereplacement algorithm(computional concept)

FIFO – An Example

7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1

707 7

01

201

231

230

430

420

423

023

013

012

712

702

701

Page 14: Pagereplacement algorithm(computional concept)

Optimal Page ReplacementLowest page fault rate of all algorithms

Free from Belady’s anomaly

Page 15: Pagereplacement algorithm(computional concept)

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.

Page 16: Pagereplacement algorithm(computional concept)

OPR – An Example

7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1

707 7

01

201

203

243

203

701

201

Page 17: Pagereplacement algorithm(computional concept)

LRU Page ReplacementFree from Belady’s Anomaly.

Problem: How to order the frame defined by the time of last use.

Solution: Counters Queue

Page 18: Pagereplacement algorithm(computional concept)

LRU – An Example

7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1

707 7

01

201

203

4

3

4

23

2

03

701

04

20

231

201

Page 19: Pagereplacement algorithm(computional concept)

Ans: C

1. Dirty bit is used to show thea. page with corrupted datab. the wrong page in the memoryc. page that is modified after being loaded into cache memoryd. page that is less frequently accessed.

Page 20: Pagereplacement algorithm(computional concept)

Ans: C

2. What replacement policy is used by Windows NTa. LRUb. NFUc. FIFOd. Clock Replacemente. None of the above

Page 21: Pagereplacement algorithm(computional concept)

Reference String

4. The string of memory references is called___________.

Page 22: Pagereplacement algorithm(computional concept)

Belady’s Anomaly

5. FIFO page replacement suffers from________________anomaly.

Page 23: Pagereplacement algorithm(computional concept)

Page fault increases with increase in number of frames.

6. What is Belady’s anomaly??

Page 24: Pagereplacement algorithm(computional concept)

TRUE

7. Optimal Page Replacement algorithm has the lowest page fault rate.

TRUE/FALSE