Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Each process has its own virtual address space, partitioned into chunks called pages. The memory is logically divided into frames of the same size, ready
Each process has its own virtual address space, partitioned into chunks called pages. The memory is logically divided into frames of the same size, ready to hold any virtual memory pages. Not all pages are loaded into the memory at the same time - only the ones that are needed by the process to run. When a process accesses a page that is not in the memory, a page fault is generated and the requested page must be brought into the memory. If there is no free memory frame to host the new page, then a victim page must be evicted from memory to make room for the new page, so that the process can continue execution. The selection of the victim page is made according to a specific page replacement policy. Page replacement algorithms assume a fixed number of memory frames that works under the following assumptions: 1. The virtual memory of the process consists of NP pages, numbered 0 through NP-1. 2. A page reference stream is a sequence of integers ranging from 0 to NP-1. Each integer represents one reference to page. 3. The main memory consists of NF frames, numbered 0 through NF-1. This is represented as an array Frames. Each entry in the array Frames contains the number of the page currently residing in that frame. The page-replacement algorithms you will be simulating are: 1. FIFO (First-In, First-Out): the first page brought in is the first to be removed. 2. LRU (Least Recently Used): the least recently accessed page is the one to be removed. Sample Input The input data is stored in a file with a format similar to the following one: \# The first integer represents the length of the reference stream. \# Subsequent integers constitute the reference stream. \# The reference stream consists of a list of pages which \# will be accessed in the order from left to right. 10012203004232 Lines beginning with ' \#' are comments and should be ignored. There is exactly one non-comment line per file. The first number in this line represents the length of the reference stream, and the remaining numbers represent the reference stream. In the example above, the length of the reference stream is 10 , and the reference stream is 1120304232 Sample Output The output of your program should result in two columns. The first column indicates the page that has been referenced, and the second column shows a snapshot of the pages loaded in memory immediately after the page reference. Here is a sample output for the reference As indicated above, your program should also compute the total number of page faults. Submission Guidelines. 1. Please upload a simple report + code (that can be run in C or C++ or Java) that contains: a) Introduction to page replacement algorithm and why the OS need it. b) Explanation of the FIFO and LRU algorithm. c) FIFO codes \& your own sample input and output. d) LRU codes \& your own sample input and output
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