【正文】
y system with pagesof size 200. A small process that manipulates the matrix resides in page0 (locations 0 to 199). Thus, every instruction fetch will be from page 0.For three page frames, how many page faults are generated bythe following arrayinitialization loops, using LRU replacement andassuming that page frame 1 contains the process and the other twoare initially empty?a. for (int j = 0。 j 100。 j++)for (int i = 0。 i 100。 i++)A[i][j] = 0。b. for (int i = 0。 i 100。 i++)for (int j = 0。 j 100。 j++)A[i][j] = 0。Answer:a. 5,000b. 50 Consider the following page reference string:1, 2, 3, 4, 2, 1, 5, 6, 2, 1, 2, 3, 7, 6, 3, 2, 1, 2, 3, 6.How many page faults would occur for the following replacementalgorithms, assuming one, two, three, four, ?ve, six, or seven frames?Remember all frames are initially empty, so your ?rst unique pages willall cost one fault each.?LRU replacement? FIFO replacement?Optimal replacement32 Chapter 9 Virtual MemoryAnswer:Number of frames LRU FIFO Optimal1 20 20 202 18 18 153 15 16 114 10 14 85 8 10 76 7 10 77 77 7 Suppose that you want to use a paging algorithm that requires a referencebit (such as secondchance replacement or workingset model), butthe hardware does not provide one. Sketch how you could simulate areference bit even if one were not provided by the hardware, or explainwhy it is not possible to do so. If it is possible, calculate what the costwould be.Answer:You can use the valid/invalid bit supported in hardware to simulate thereference bit. Initially set the bit to invalid. On ?rst reference a trap to theoperating system is generated. The operating system will set a softwarebit to 1 and reset the valid/invalid bit to valid. You have devised a new pagereplacement algorithm that you think maybe optimal. In some contorted test cases, Belady’s anomaly occurs. Is thenew algorithm optimal? Explain your answer.Answer:No. An optimal algorithm will not suffer from Belady’s anomaly because—by de?nition—an optimal algorithm replaces the page that will notbe used for the longest time. Belady’s anomaly occurs when a pagereplacement algorithm evicts a page that will be needed in the immediatefuture. An optimal algorithm would not have selected such a page. Segmentation is similar to paging but uses variablesized“pages.”De?netwo segmentreplacement algorithms based on FIFO and LRU pagereplacement schemes. Remember that since segments are not the samesize, the segment that is chosen to be replaced may not be big enoughto leave enough consecutive locations for the needed segment. Considerstrategies for systems where segments cannot be relocated, and thosefor systems where they can.Answer:a. FIFO. Find the ?rst segment large enough to acmodate theining segment. If relocation is not possible and no one segmentis large enough, select a bination of segments whose memoriesare contiguous, which are “closest to the ?rst of the list” andwhich can acmodate the new segment. If relocation is possible,rearrange the memory so that the ?rstNsegments large enough forthe ining segment are contiguous in memory. Add any leftoverspace to the freespace list in both Exercises 33b. LRU. Select the segment that has not been used for the longestperiod of time and that is large enough, adding any leftover spaceto the free space list. If no one segment is large enough, selecta bination of the “oldest” segments