Page Replacement Algorithm Calculator

Effortlessly calculate and simulate Page Replacement Algorithms with our interactive tool. Explore algorithms like FIFO, LRU, Optimal, and more. Ideal for students, developers, and computer science enthusiasts.

Page References:
No. of Frame:
Algorithm:

Step-by-Step Calculation

Pages: [4,7,6,1,7,6,1,2,7,2]

Total Page Faults: 6

No. of Frame: 3

Step: 1

Page: 4 → Fault, Add to Frame: [4]

Frame Before: []

Frame After: [4]

Reason: Page added as frame is not full.

Explain: (Page Fault), because page 4 not in frames so added to frames.

Step: 2

Page: 7 → Fault, Add to Frame: [4, 7]

Frame Before: [4]

Frame After: [4, 7]

Reason: Page added as frame is not full.

Explain: (Page Fault), because page 7 not in frames so added to frames.

Step: 3

Page: 6 → Fault, Add to Frame: [4, 7, 6]

Frame Before: [4, 7]

Frame After: [4, 7, 6]

Reason: Page added as frame is not full.

Explain: (Page Fault), because page 6 not in frames so added to frames.

Step: 4

Page: 1 → Fault, Evited: 4, (Least Recently Used), Add 1 and Remove 4 → Frame: [7, 6, 1]

Frame Before: [4, 7, 6]

Frame After: [7, 6, 1]

Reason: FIFO Evicted page 4 and added 1.

Explain: (Page Fault), because page 1 not in frames so added to frames.

Step: 5

Page: 7 → No Fault, Already in frame → Frame: [7, 6, 1]

Frame Before: [7, 6, 1]

Frame After: [7, 6, 1]

Reason: Page 7 already in frame.

Explain: (No Page Fault), because page 7 found in frames.

Step: 6

Page: 6 → No Fault, Already in frame → Frame: [7, 6, 1]

Frame Before: [7, 6, 1]

Frame After: [7, 6, 1]

Reason: Page 6 already in frame.

Explain: (No Page Fault), because page 6 found in frames.

Step: 7

Page: 1 → No Fault, Already in frame → Frame: [7, 6, 1]

Frame Before: [7, 6, 1]

Frame After: [7, 6, 1]

Reason: Page 1 already in frame.

Explain: (No Page Fault), because page 1 found in frames.

Step: 8

Page: 2 → Fault, Evited: 7, (Least Recently Used), Add 2 and Remove 7 → Frame: [6, 1, 2]

Frame Before: [7, 6, 1]

Frame After: [6, 1, 2]

Reason: FIFO Evicted page 7 and added 2.

Explain: (Page Fault), because page 2 not in frames so added to frames.

Step: 9

Page: 7 → Fault, Evited: 6, (Least Recently Used), Add 7 and Remove 6 → Frame: [1, 2, 7]

Frame Before: [6, 1, 2]

Frame After: [1, 2, 7]

Reason: FIFO Evicted page 6 and added 7.

Explain: (Page Fault), because page 7 not in frames so added to frames.

Step: 10

Page: 2 → No Fault, Already in frame → Frame: [1, 2, 7]

Frame Before: [1, 2, 7]

Frame After: [1, 2, 7]

Reason: Page 2 already in frame.

Explain: (No Page Fault), because page 2 found in frames.

Rules of the Least Recently Used (LRU)

1. Page Reference Arrival:

For each page reference (requested page):

  • Check if the page is already in the frame.
  • If yes, it is a page hit (no page fault).
  • If no, it is a page fault, and a replacement may be required.

2. Page Replacement Rules (In Case of Page Fault):

  • If a Frame is Available
  • Insert the requested page into the frame.

If All Frames are Occupied,

  • Identify the page that has been used the least recently.
  • Evict the least recently used page from the frame.
  • Insert the requested page into the freed frame.

3. Updating Usage Information:

  • Every time a page is accessed (whether it's a hit or a fault), mark it as the most recently used.
  • Update the usage information for all pages in the frame.

Explain with Table

Step Page Frames Before Fault Evicted Frames After Reason
1 4 Yes - 4 Page added as frame is not full.
2 7 4 Yes - 4, 7 Page added as frame is not full.
3 6 4, 7 Yes - 4, 7, 6 Page added as frame is not full.
4 1 4, 7, 6 Yes 4 7, 6, 1 FIFO Evicted page 4 and added 1.
5 7 7, 6, 1 No - 7, 6, 1 Page 7 already in frame.
6 6 7, 6, 1 No - 7, 6, 1 Page 6 already in frame.
7 1 7, 6, 1 No - 7, 6, 1 Page 1 already in frame.
8 2 7, 6, 1 Yes 7 6, 1, 2 FIFO Evicted page 7 and added 2.
9 7 6, 1, 2 Yes 6 1, 2, 7 FIFO Evicted page 6 and added 7.
10 2 1, 2, 7 No - 1, 2, 7 Page 2 already in frame.