Question: 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

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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!