Professional Documents
Culture Documents
b c a c b a d c b
OPT
Least Recently Needed(LR N)
mri mri
mri
lri lri
lri
b c a c b a d c b not in in
mri b c a a a a d d b
b c c c c a a d
lri * * b* b* b* b* c* c* a*
M M M H H H M H M
b c
d *
mri mri
a a a no change
H A hit lri lri
mri
d
M A miss b
c c c
b lri
FIFO
Least Recently In (LR I)
not in in
b c a c b a d c b
mru b c a c b a d c b
b c a c b a d c
lru * * b* b* a* c* b* a* d*
M M M H H H M M M
c b a *
LRU
Least Recently Used
b c a c b d b a c b
SECOND b1 c1 a1 a0 a0 d1 d0 d1 c1 b1
CHANCE
make 1
b0 c0 c1 c0* b0 b1 b0* a0 c0
FIFO *
* * *
b0 *
b0 b1 a0* a0 a1 d0 a0*
* *
M M M H H M H H M M
c0 b0 d0 if * is 0 if * is 1
d
next=0
mri mri lri-and not recently used
a0 a0 a0
referenced no referenced
in clock in clock
AGING period period
1 register replace low
110 1 011 0
per page 0 0 0 0 1 0 0 0 0 1 0 0 101 0
binary numbers
4 f mri
out e 5
g
in
f e d c b a
out
f e d c b a
= 3
d
a
0
5 4 3 210 5 43 21 0 2 b
g in c 1
a 3 f
out e 4
=
g
h g f e d c b a f e d c b g 2
d
mri
5
in out
5 4 3 2 10 4 3 210 5 1c
b
0lri
a
h in
b a
out
h g f e d c b a f e d c h g
i out
in
3 2 1 0 5 4
i in
d c b a
out
d c b a f e j i h g
k j i h g f e
in out 1 0 5 4 32
k in
e d c b a
out
l k j i h g f out e d c b a f k j i h g
in
0 5 4 3 21
l in
f e d c b a
out
m l k j i h g f e d c b a l k j i h g
in out
5 43 21 0
m in
FIFO-Push Down FIFO-Cicular
360
0 tst
180
0
Time
Process
@ Degree
0 360
180
tst
Time
Process
@ Degree
0 360
180
0
tst Time
Test Hand- tests for 1 = recently
referenced, if so do not replace,
otherwise replace
Clear Hand- make 0 = not recently
referenced
interval during which a page can
be referenced and get a second
chance
1 2 3 4
1 0 1 1 1 0 1 0 1 0 0 0 1 0 0 0 0 0 1 1 1 0 0 1 1 1
2 0 0 0 0 0 0 0 0 1 0 1 1 1 0 1 0 0 0 1 0 1 0 1 1 2
3 0 0 0 0 1 1 0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 3
4 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 0 0 0 1 0 4
at the end ( ) at the end at the end 0 in at the end
( 1 )
in row 3
0 in 2 0 in
in row 1 cols in row 2 0 in
in row 4 cols 2 2
cols 2 cols 2
1 1 1 only
4 4 only
the end
3 only
only
In the final matrix there is exactly one 0 in row , 2. There are exactly two 0s in row 1,
because the last two pages referenced are 1 and 2. There are exactly three 0s in row 4
because the last three pages referenced were 1, 2 and 4. We can ignore the fact thatt
another use of page 2 occured earlier. There are exactly four 0s in row 3 because the
last four pages referenced were 1, 2, 3, and 4
1 (N-> 2) 2 (N- 3) (N-> N-2) N-2 (N-> N-1) N-1 (Ns) N has
0 in 0 in 0 in 0 in 0 in
cols N cols N cols N cols N cols N
N-1 N-1 N-1 N-1
N-2 N-2 N-2
3
2
GENERAL
0 10 20 30
0 10 20 30 30 40 50 50 60 70 80 90
Process or Virtual Times)
I1 w(I1,t) = {p2,p4}
p1. p2. p1.p1. . p2. . p4.p3. . . p2. . . p1. p2. p1. . p3. . p1. p2p1. . . p2. . p4
w(I2,t) = {p1,p2,p3}
I2
WORKING SET
Given that MM1 has fewer page frames than MM2:
If whenever ALG is used to allocate the same page input sequence to both MM! and MM2., every page
in MM1 is always also in MM2 , ALG is a STACK REPLACEMENT ALGORITHM..
Page Input
Sequence
a b c a d
1 a b c a d
2 _* a* b* c* a
U U U U U
Page
Frames
1 a b c c d
2 _*
a b b c
3 _ _* a* a* b*
FIFO Replacement Algorithm
So for FIFO it is necessary to keep tables having 1, 2, ...., n rows to record
the result of a simulation of all MMs having any number of pages from 1 to n.
So 1 + 2 +...+ n = O(n2) rows are required.
.
For a Stack Algorithm only n rows are required to record the result of
a simulation of all MMs having any number of pages from 1 to n.
STACK ALGORITHM
FIFO IS NOT ONE
Page Input Sequence
a b c a d e c e
1 a* b* c* a* d* e*c* e*
2 _ a* b* c* a* d*e* c*
Page
3 _ _ a* b* c* a*d* d*
Frames 4 _ _ _ _ b* c * a* a*
5 _ _ _ _ _ b* b*
b*
_ _ _ _ _ _ _ _
6
3 4 2
8
8
8
8
8
The Distance String
At any stage in the reception of the input page sequence the page that would be removed
if the next page input required a replacement is the dispensable one.
Unloke when using LRU, using OPT all pages in the table are starred. The
dispensable pages in each column are determined by the order in which those
pages in MM will again arrive in the future.
a b c a d e c e d b a e
1 a* b*c* a* d* e* c* e* d*
_ a a c c c e c* e
2
Page 3 _ _ b* b b* d* d d c*
Frames 4 _ _ _ _
a* b* b b b
5 _ _ _ _ _ a* a a a
_ _ _ _ _ _ _ _ _
6
2 2 2 3
8
8
8
8
8
C =5 C3 = 1 C2= 3
8