1
$\begingroup$

Studying LRU approximation Algorithms I think to have not understand how it works, for example:

consider a process with 3 logical pages and 2 frames allocated , an approximation of the
Algorithm Last Recently Used based of reference bits where every four references there is
a shift and where are considered just the first 2 bits, and the follow reference string:

1 2 1 1 1 1 0 1 0 0

I'd solve it in this way:

1 2 1 1 (m1) 1 1 (m2) 0 1 0 0

(m1)

4 references so I'd pass from

 frame                     frame
 -----+---+---     to       -----+---+---
    1 | 1 | 0                  1 | 0 | 1 
    2 | 1 | 0                  2 | 0 | 1 

(m2)

page fault so I'd pass from

 frame                     frame
 -----+---+---     to       -----+---+---
    1 | 1 | 1                  1 | 0 | 0 
    2 | 0 | 1                  0 | 0 | 0 

So the questions are:

  • Is my doing correct?
  • At m2 there is a page fault, is there a "reset" and all bits puts at 0?
  • the shift frequency (4 in the example) restart counting every page fault?
$\endgroup$
2
$\begingroup$

Is my doing correct?

If I don't misunderstand your notation, when you manipulate the frame for first time (filling it with page 1, then page 2) and then page 1 is called again, you shouldn't send to disk page 2, there is no need because page 1 it is already in frame.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.