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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started