Page Replacement Algorithms
Page Replacement Algorithms
Python Code:
pages = [1, 3, 0, 3, 5, 6, 3]
capacity = 3
fifo_page_replacement(pages, capacity)
FIFO Page Replacement Algorithm (Python Code)
class LRUCache:
def __init__(self, capacity: int):
self.cache = OrderedDict()
self.capacity = capacity
self.total_page_faults = 0
def display(self):
print("Current Cache State:", list(self.cache.keys()))
print("Total Page Faults:", self.total_page_faults)
lru = LRUCache(3)
pages = [1, 2, 3, 1, 4, 5]