Write a program that implements the FIFO, LRU, and optimal page-replacement algorithms. The… 1 answer below »

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.


Order a Similar Paper Order a Different Paper

Write a program that implements the FIFO, LRU, and optimal page-replacement algorithms. The program must be a Python script file named Project3.py with 3 functions defined within the file. The functions must be named FIFO, LRU and OPT. Each function must take two arguments: the first argument must be the reference string (a Python list), and the second argument must be the maximum number of frames in memory (an integer). Each function must return the number of page faults as an integer. The example below shows the functions being called with a specific reference string and maximum number of frames in memory, with the return values from each function call.

>> ref_str = [7, 0,1,2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1]

>> n = 3

>> FIFO(ref_str, n)

15

>> LRU(ref_str, n)

12

>> OPT(ref_str, n)

9