Skip to content

Page replacement algorithms to analyse page fault and belady's anomaly.

License

Notifications You must be signed in to change notification settings

tushar-c23/PageReplacement_Algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PageReplacement_Algorithms

Page replacement algorithms to analyse page fault and belady's anomaly and thrashing.

Algorithms

  1. Least Recently Used (LRU)
  2. 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:
    1. Maximum frame size
    2. Maximum page array size (the maximum number of pages in the reference string)
    3. 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

  1. Clone the repository
  2. 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
  3. 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>"

Footnotes

  1. Note: All three command line args must be provided.