0

I have a question and I am not sure about it.

A computer memory with a total of three physical pages, and page reference sequence: 1, 2, 3, 2, 1, 4, 3, 5, 6, 4, 3, 5, 3, 5, 6, 7, 2, 1, 5, 7. Use optimal, FIFO, and LRU page replacement algorithms.

I have try, but I'm not sure about my answer. Also, in this case, which one is a good algorithm? Why?

my answer: my answer

optimal: PF 10

FIFO: PF 12

LRU: PF 16

Arya McCarthy
  • 8,554
  • 4
  • 34
  • 56
selene Qu
  • 13
  • 1
  • 3
  • Your calculations look correct. So what is the Problem with the rest of your assignment? You are probably worrying or overthinking too much. It seems there are only 2 possible answers. Either this is a real-world problem and FIFO is the best since it has fewest PFs or this is a plastic problem and *optimal* is the best since it's always the best strategy if you know the page load sequence in advance - hence the name *optimal* for [Bélády's Algorithm](https://en.wikipedia.org/wiki/Cache_replacement_policies#B.C3.A9l.C3.A1dy.27s_Algorithm). – makadev May 23 '17 at 14:57

2 Answers2

0

If we analyze theoretically, then Optimal Page Replacement algorithm is the best. Reasons for that:

  • It minimize the page faults (Least Page Faults among all Page Replacement Algorithms)
  • It overcomes Belady's anomaly

But the problem with this algorithm is, it require future knowledge of required pages i.e. which page will be demanded to fetch in the memory, which is not possible all the times.

If the pages are already known, then you must go with OPR algorithm. Otherwise, based on page demanded, analyse the cost of each algorithm and implement that page replacement policy which causes minimal page faults.

0

The main thing for any page replacement is the access pattern/sequence of pages. This access varies per the runtime workload of the OS.

If we can clearly see access patterns and can predict future required pages, then 'optimal page replacement' is the best. As mentioned by sanjay in the other answer, it minimizes page faults.

If the pattern cannot be predicted, LRU could be decent for most of the real-world workloads. But some work-load may show FIFO outperforming LRU. You can find the discussion of the same here.

arunk2
  • 2,246
  • 3
  • 23
  • 35