Question: Part 0 - Random number generator ( 1 0 points ) To begin writing our paging simulator, we'll need to generate a sequence of memory
Part Random number generator points
To begin writing our paging simulator, we'll need to generate a sequence of memory addresses.
As a program executes, it generates virtual memory addresses for as long as the program runs. To simulate this, we'll be generating addresses using a random number generator.
As a caveat, the addresses generated by a typical program aren't truly random, since in practice, there will always be some group of pages a process will frequently access. As a standin for this, we'll generate two random numbers and add them together. This forms an uneven distribution, not unlike that of rolling two dice, where there are more ways to roll a than there are to roll a or
Image from Edward D Collins'webpage
edcollins.com.
Begin with the following RNG shown below.
For ease of understanding, these addresses are for a theoretical base computer, with the lower three digits used as the offset and the higher two digits used as the page number. Because numbers are being capped at and two such random numbers are being added together, this means addresses range from to This means there are different pages for our simulated program to access: pages to where pages and are accessed most frequently.
Modify this program further so instead of the entire address being printed, only the page number is printed.Run this program and take a screenshot of its output.Part : FIFO Page Replacement pointsNow that we have a means of "generating" addresses and getting their corresponding page numbers, we can implement our first page replacement algorithm: FIFO page replacement. Begin by adding the line #include
Part : FIFO Page Replacement points
Now that we have a means of "generating" addresses and getting their corresponding page numbers, we can implement our first page replacement algorithm: FIFO page replacement.
Begin by adding the line #include
Part : LRU page replacement points
With FIFO complete, we can now add our next page replacement algorithm: LRU. Before you start, you may want to comment out some of the cout lines being used for debugging, as they may get in the way at this point.First, add another list and page fault counter for LRU. This second queue will be used for the LRU's "stack". As mentioned in lecture, this isn't a stack, but we'll permit this abuse of terminology for ease of explanation. LRU "stack" And LRU page fault countstd: :list
Part : Benchmarking points
From the two screenshots of your program running, take the sequence of page numbers and manually perform optimal page replacement OPT on the two sequences. You may use an online tool to verify your results.
For the screenshot taken in part you're comparing the performance of FIFO with OPT, with five page frames. For the screenshot taken in part you're comparing the performance of both FIFO and LRU with OPT, with five page frames.
For the two sequences of page numbers, did OPT yield a lower pagefault count?
Part : Testing only one sequence of addresses points Modify your code so that it has an array or alternatively, a vector of page numbers. You may use one set of page numbers from part Your code should look something like what's shown below.
Modity your code so instead of using the RING to generate your page numbers, you instead access the array of page numbers.This modification is so we can test out how adding more page frames affects the number of page faults, which cannot be tested if the page numbers change with each test. First, modify your page frame count to How many page faults did you get for both FIFO and LRU?Next, increase the page frame count to How many page faults did you get for both FIFO and LRU?Slowly increase the number of page frames by one each time, recording the number of page faults that LRU and FIFO produce. Use this information to fill out the table below dotsFIFOLRU
Hint: you don't need to fill out the entire table! You can stop at the number of page faults you had when you tried page frames! Because your program visits some pages more than once due to the uneven distribution, page frames is overkill, and you can get away with fewer page frames. Part : Did you get something weird? points Based on your results, you may think that increasing the number of page frames should reduce the number of page faults. In the study of paging algorithms is Belady's anomaly, which states that an increase in page frames does not necessarily reduce the number of page faults, and in some cases, it may even lead to an increase.
Did you experience Belady's anomaly? Due to the random nature of the RNG your experiment may or may not have resulted in Belady's anomaly appearing.
If you did experience Belady's anomaly, compare the number of page faults for FIFO and LRU.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
