Search code examples
listfifopage-faultpage-replacement

FIFO Page Replacement Algorithm - Counting Page Faults


I'm currently reading about Page Replacement Algorithms, and have been looking at a couple of examples with regards to the FIFO (First In, First Out) method.

My question is as follows; how do you count the number of page faults, as I have seen different practices.

For instance: Example 1 (on page 9) and Example 2 take the exact same sequence. The first counts the number of page faults to be 12, whereas the second states the number is 15. They are using the same number of frames, 3.

The sequence is:

Sequence: 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
         -----------------------------------------
          7 7 7 0 0 1 2 3 0 4 2 2 2 3 0 0 0 1 2 7
            0 0 1 1 2 3 0 4 2 3 3 3 0 1 1 1 2 7 0
              1 2 2 3 0 4 2 3 0 0 0 1 2 2 2 7 0 1
         -----------------------------------------
PF (1):         *   * * * * * *     * *     * * *  Total = 12 page faults
PF (2):   * * * *   * * * * * *     * *     * * *  Total = 15 page faults

Hence, my question is; which method is the correct method? Do you count the first three instances as page faults?

If so, given the sequence:

Sequence: A B C D A E F G H I A J
         -------------------------
          A A A A A B C D E F G H
            B B B B C D E F G H I
              C C C D E F G H I A
                D D E F G H I A J
         -------------------------
 PF (1):  * * * *   * * * * * * *  Total = 11 page faults
 PF (2):            * * * * * * *  Total = 7 page faults      

Any help would be highly appreciated. Thank you guys!


Solution

  • "Hence, my question is; which method is the correct method? Do you count the first three instances as page faults?"

    Yes. Page Fault occurs when you don't fined the referenced page in the frames. Therefore, the first entries are always PFs.