Dashboard Temp Share Shortlinks Frames API

HTMLify

Page Replacment Algotithems in Python
Views: 642 | Author: abh
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# Page Replacment Smulator

def FIFO(string: list["anything"], frames=3):
    page = [None]*frames
    pages = []
    status = []
    i = 0
    for c in string:
        if c in page:
            status.append(True)
        else:
            status.append(False)
            page[i] = c
            i = (i+1)%frames
        pages.append(page.copy())
    return pages, status, (status.count(True)/len(status))

# LRU function to be added