PageReplacement_Algorithms
Page replacement algorithms to analyse page fault and belady's anomaly and thrashing.
Algorithms
- Least Recently Used (LRU)
- Most Recently Used (MRU)
Some Useful Information
- The reference string is randomly generated using a seed value. This seed value is generated using the current time. So, the reference string will be different every time the program is run.
- The user can provide 3 values as command line arguments. These values are:
- Maximum frame size
- Maximum page array size (the maximum number of pages in the reference string)
- Flag
Flags
- sf: Fixed reference string for each call as the frame size increments.
- sr: Random reference string for each call as the frame size increments.
How to run
- Clone the repository
- Run the following commands in the terminal to compile the code:
g++ mru.cpp pbPlots.cpp supportLib.cpp -lm -o mru
g++ lru.cpp pbPlots.cpp supportLib.cpp -lm -o lru
- Run the following commands in the terminal to generate plots:
./mru <maxFrameSize> <maxPageArraySize> -<flag>
./lru <maxFrameSize> <maxPageArraySize> -<flag>
Replace the placeholders with the desired values. [^1]
This program will generate plots for the algorithms in "./plots/" folder.
Naming convention for the plots is as follows:
"\<Algorithm Name>-\<flag>-\<maxFrameSize>-\<maxPageArraySize>"
[^1]: Note: All three command line args must be provided.