page replacement algorithms and simulation neville allen

11
Page Replacement Algorithms and Simulation Neville Allen

Upload: christopher-russell

Post on 17-Jan-2016

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Page Replacement Algorithms and Simulation Neville Allen

Page Replacement Algorithms and Simulation

Neville Allen

Page 2: Page Replacement Algorithms and Simulation Neville Allen

Introduction

• Page replacement algorithms decide which page to swap out from memory to allocate a new page to memory.

• Page fault happens when a page is not in memory and needs to be placed into memory

• The idea is to find an algorithm that reduces the number of page faults which limits the time it takes to swap in and swap out a page

Page 3: Page Replacement Algorithms and Simulation Neville Allen

First In First OutFIFO

• Simple queue structure, the page at the head of the queue gets swapped out when a new page needs to be allocated

• The new page gets added to the end of the queue

Page 4: Page Replacement Algorithms and Simulation Neville Allen

Least Recently UsedLRU

• Min_array that kept track of count value • When page needs to be swapped out look

through min_array to find the min value and swap the value from reference array to frame array

Page 5: Page Replacement Algorithms and Simulation Neville Allen

Most Recently UsedMRU

• Max array keeps track of values of count value• When page needs to be swapped out find the

max value in max array and swap the value from reference array to frame array

Page 6: Page Replacement Algorithms and Simulation Neville Allen

Second Chance

• Bit array that keeps track of one or zero for the particular value from the reference array

• When a page needs to be swapped out searches through bit array to find a zero, when it finds a zero it puts the value in reference array to the frame array. If a one is entered it changes the value in bit array to zero and keeps looking for another zero

Page 7: Page Replacement Algorithms and Simulation Neville Allen

Optimal

• This is in theory the best algorithm to use for page replacement.

• This algorithm looks ahead to see the likely hood that a value in the frame array is going to come up soon. If the value in value array doesn’t come up soon it will be swapped out when a new page needs allocated

Page 8: Page Replacement Algorithms and Simulation Neville Allen

ResultsFrames = 3 Range = 5

1000 2000 2500 3000 3500 4000 4500 5000 55000

500

1000

1500

2000

2500

FIFO 4LRU MRU 32nd Chance 2

Page 9: Page Replacement Algorithms and Simulation Neville Allen

Results Frames = 3 Range = 10

1000 2000 2500 3000 3500 4000 4500 5000 55000

500

1000

1500

2000

2500

3000

3500

4000

4500

FIFO 2LRU 1MRU 42nd Chance 2

Page 10: Page Replacement Algorithms and Simulation Neville Allen

ResultsFrames = 3 Range = 15

1000 2000 2500 3000 3500 4000 4500 5000 55000

500

1000

1500

2000

2500

3000

3500

4000

4500

5000

FIFO 2LRU 1MRU 32nd Chance 3

Page 11: Page Replacement Algorithms and Simulation Neville Allen

Results

• I found that MRU and FIFO were some of the best algorithms

• Keeping the frame the same when I doubled the range of numbers from 5 to 10 the page faults less then doubled

• Increasing the range from 5 to 15, doubles the amount of page faults