Вы находитесь на странице: 1из 22

Page Replacement Algorithm style Click to edit Master subtitle

- Presented by: Yogita Chichani

page replacement policy

5/4/12

Virtual Memory
Virtual Memory means the memory not in existence. Able to execute the program of capacity larger than the available main memory size. Allows the execution of process that may not be completely in memory. Allows to execute a program which is partially in memory.
5/4/12

page replacement policy page replacement policy

(conti..)
Program generated addresses are

called virtual address.


The virtual address space is divided

into fixed size of unit called Pages.


The corresponding unit in physical

memory are called page frames.


Page fault means the desired page

not in memory at the time of demand.


page replacement policy page replacement policy

5/4/12

Page Replacement
This approach involves preempting a

region R occupied by block K and allocating it to incoming block K. The criteria used for selecting K as the block to be replaced constitute replacement policy.
Objective of choosing a replacement

policy is to minimize the page fault.


We could also increase degree of
page replacement policy page replacement policy

multiprogramming.

5/4/12

Issues
When a page is to be removed from

memory?
Does it have to be one of the faulting

process?
Own pages or can it be a page

belonging to another process?


page replacement policy page replacement policy

5/4/12

The string of memory reference is

called reference string.


For e.g.

If we trace a particular process, we record address sequence: 0100,0432,0101,0612,0102,0611 This sequence is reduced to reference string
page replacement page replacement policy policy

1,4,1,6,1,6

5/4/12

Optimal Page Replacement(OPT)


Replace page that will not be used for

longest period of time.

OPT replacement associates with

each page the time of that pages is not to be used.


page replacement policy page replacement policy

5/4/12

OPT
Example:

page replacement policy page replacement policy

5/4/12

OPT
Advantage:

1. Lowest page fault rate.


Disadvantage:

1. Difficult to implement as future knowledge of reference string is required.


page replacement policy page replacement policy

5/4/12

FIFO page replacement


FIFO works on first in first out FIFO replacement algorithm associates

with each page the time when that page was brought into memory.
The oldest page is chosen for

replacement.
When a page is brought in to memory

then it is inserted at the tail of the list.


page replacement policy 5/4/12

FIFO
Example:

page replacement policy

5/4/12

FIFO
Advantages :

1.Easy to understand and program. 2.Page replaced that was used long time ago & is no longer needed.
Disadvantages:

1.Performance is not good as increases the page fault rate.


page replacement policy 5/4/12

Least Recently Used(LRU)


LRU replacement associates with

each page the time of that pages last use.


LRU chooses the page that has not

been used for longest period of time.

page replacement policy

5/4/12

LRU
Example:

page replacement policy

5/4/12

LRU
Advantages :

1.Less no. of page faults. 2.Considered to be good.


Disadvantages:

1. Requires substantial hardware assistance. 2. Difficult to implement. 3. List must be updated on every page replacement policy 5/4/12 memory reference.

Not Recently Used(NRU)


Virtual memory have 2 status bits

associated with each page i.e. R and M


R is set whenever the page is

referenced (read or written).


M is set when page is written to.

(modified)
When page fault occurs the OS

inspect all the pages & divide them page replacement policy 5/4/12 into 4 categories based on the value

NRU
Class 0: Not referenced, not modified. Class 1: Not Referenced, modified. Class 2: reference ,not modified. Class 3: referenced , modified

The NRU removes a page at random from the lowest numbered nonempty class.
page replacement policy 5/4/12

NRU
Advantages:

1. Easy to understand. 2. Efficient to implement.


Disadvantages:

1. Performance certainly not optimal.

page replacement policy

5/4/12

Summary
Algorithm Optimal NRU FIFO LRU Comment Not implementable Very crude approximation of LRU Might throw out important pages Excellent , but difficult to implement.

page replacement policy

5/4/12

References
Operating System Concepts 7th ed

- Silberschatz Galvin
Operating Systems Design and

Implementation, 2Ed
- Tanenbaum, Andrew S.

www

page replacement policy

5/4/12

Any Question ?

page replacement policy

5/4/12

Thank you!
For Patient Listening

page replacement policy

5/4/12