Programming Assignment 4: Write A Simulation Of
In Programming Assignment 4 You Are To Write A Simulation Of A Pagere
In programming assignment #4 you are to write a simulation of a page replacement memory management system. You will be implementing least recently used (LRU) and first-in-first-out (FIFO) page replacement schemes (Chapter 8, pg 369). Your program should read from a file to get information about the sequence of page faults that occur. I will provide a simple example of such a text file. It consists simply of one integer value per line, which represents the sequence of page requests.
Paper For Above instruction
The task of this assignment is to develop a simulation program that models the behavior of a memory management system utilizing two widely used page replacement algorithms: Least Recently Used (LRU) and First-In-First-Out (FIFO). The purpose of the simulation is to analyze and compare the efficiency of these algorithms under different page reference sequences, which are supplied via an input file.
The simulation must accurately emulate how a physical memory handles page requests by loading pages into a limited number of frames. When a page request arrives, if the page is already in memory (a hit), no change occurs. If the page is not present (a miss), the system must decide which page to replace based on the selected algorithm.
The input file will contain a sequence of integers, each representing a page number requested at a unique time step. The program should process this sequence sequentially, recording the number of page faults that occur during the simulation. It is essential that the program allows the user to specify the number of available frames, as this impacts the behavior and statistics of the simulation.
The core functions of the program include:
- Reading and parsing the input file.
- Implementing the FIFO algorithm, which replaces the oldest page in memory when needed.
- Implementing the LRU algorithm, which replaces the page that has not been used for the longest time.
- Tracking and reporting the total number of page faults for each algorithm.
The design should feature modular, well-structured code for clarity and reusability. For example, separate functions should handle reading input, executing each algorithm, and outputting results.
In terms of implementation, the FIFO scheme can be managed with a queue data structure, where pages are enqueued when loaded and dequeued during replacement. The LRU scheme can be efficiently implemented with a list or a more sophisticated data structure such as a linked list combined with a hash map for quick access, or by using a built-in ordered dictionary for tracking page usage.
Evaluation of the simulation involves running the program with various reference sequences and frame sizes to observe how the page fault rate changes. The results can provide insight into the relative performance of FIFO and LRU, particularly their tendencies to under- or over-replace depending on the access patterns.
In conclusion, this assignment offers a practical application of fundamental concepts in operating systems concerning virtual memory management. It emphasizes data structure selection, algorithm implementation, file I/O operations, and performance analysis. Mastery of these skills enhances understanding of how real-world systems manage memory efficiently under different workload conditions.
References
- Silberschatz, A., Galvin, P. B., & Gagne, G. (2018). Operating System Concepts (10th ed.). John Wiley & Sons.
- Tanenbaum, A. S., & Bos, H. (2014). Modern Operating Systems (4th ed.). Pearson.
- Stallings, W. (2018). Operating Systems: Internals and Design Principles (9th ed.). Pearson.
- Galvin, P., & Silberschatz, A. (2006). Operating System Concepts Essentials. Wiley.
- Majumdar, A., & Mongia, V. (2019). Simulation of Page Replacement Algorithms. International Journal of Computer Applications, 178(35), 25-30.
- Operating System - Page Replacement Algorithms. GeeksforGeeks. https://www.geeksforgeeks.org/page-replacement-algorithms-in-operating-systems/
- Page Replacement Algorithms in Operating Systems. TutorialsPoint. https://www.tutorialspoint.com/operating_system/os_page_replacement_algorithm.htm
- Page Replacement Strategies (FIFO & LRU). Educative.io. https://www.educative.io/blog/page-replacement-strategies
- Linux Kernel Memory Management. Linux Kernel Documentation. https://www.kernel.org/doc/html/latest/vm/index.html
- Implementation of Page Replacement Algorithms in C. GeeksforGeeks. https://www.geeksforgeeks.org/implementation-of-page-replacement-algorithms-in-c/