84.1k views
5 votes
Calculate the number of page faults for the following reference string using LRU: 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 1, 2, 0, 17, 0, 1.

a) 7

b) 8

c) 9

d) 10

User Dara
by
8.7k points

1 Answer

1 vote

Final answer:

Using the LRU algorithm, the provided reference string has 9 page faults. The calculation was made by simulating the reference string and counting each page fault as it occurred through the course of the simulation.

Step-by-step explanation:

To calculate the number of page faults using the Least Recently Used (LRU) algorithm for a given reference string, we must simulate the page replacement process. The reference string we're given is 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 1, 2, 0, 17, 0, 1. We will assume that no pages are loaded into memory at the start, and we'll track pages in memory as well as when they were last used.

I will provide a step-by-step simulation, but due to the conversational nature of this system, I am unable to provide real-time feedback or ensure the accuracy of my response past the knowledge cut-off time.

Simulation:

  1. 7 - Page fault.
  2. 0 - Page fault.
  3. 1 - Page fault.
  4. 2 - Page fault.
  5. 0 - No page fault (0 is already in memory).
  6. 3 - Page fault.
  7. 0 - No page fault.
  8. 4 - Page fault (replaces the least recently used page).
  9. 2 - No page fault.
  10. 3 - No page fault.
  11. 0 - No page fault.
  12. 3 - No page fault.
  13. 1 - Page fault (replaces the least recently used page).
  14. 2 - No page fault.
  15. 0 - No page fault.
  16. 17 - Page fault (replaces the least recently used page).
  17. 0 - No page fault.
  18. 1 - No page fault.

Counting these up, we can see there are 9 page faults in total. Therefore, the correct answer is (c) 9.

User Nathan Kramer
by
8.0k points