Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please answer this question with caution. And also What if we using Least Recent

ID: 3905916 • Letter: P

Question

Please answer this question with caution. And also What if we using Least Recently Used or Optimal algorithm?

Please give 3 answer and explanation for all 3 cases: First in first out/Least Recently Used/Optimal algorithm. Thanks

Select the best answer. Consider these page references (time is progressing left to right): 1 3 6 1 3 X 6 3 1 The objective is to select the page to replace using First-In First-Out. Assume that when Reference X is made, the main memory for this process contains these pages: 3 6 Select the page to replace. None of these answers 6

Explanation / Answer

Page Replacement Algorithms

Before we go to the question let me explain those three algorithms

Page Fault is loading the page into memory

First In First out : In this the first page came into memory is replaced with the required page.

Page References be                 3 4 5 2 1

Then first three pages are loaded into the memory one by one cause 3 page faults

page memory   has     3(1st) 4(2nd) 5(3rd) pages

then 2 has to be loaded therefore first loaded page will be replaced result 1 page fault

page memory has      2     4      5 pages

then page 1 has to loaded into the memory therefore 4 will be replaced causing 1 page fault.

Page memory has 2 1 5 pages.

Least Recently Used: In this least recently used pages will be replaced .

Let page reference be            3 4 3 5 6 1

Then first three pages are loaded into the memory one by one cause 3 page faults

page memory   has     3(1st) 4(2nd) 5(3rd) pages

then 6 has to be loaded therefore from first least recently used that is page 4 will be replaced resulting 1 page fault

page memory has        3   6      5 pages

then page 1 has to loaded into the memory therefore 5 will be replaced causing 1 page fault.

Page memory has 3 6 1 pages.

Optimal algorithm : I t replaces the page which is not used for longest time.

Let page reference be            3 4 3 5 6 1

Then first three pages are loaded into the memory one by one cause 3 page faults

page memory   has     3(1st) 4(2nd) 5(3rd) pages

then 6 has to be loaded therefore page not used for longest period, that is page 4 will be replaced result 1 page fault

page memory has        3   6      5 pages

then page 1 has to loaded into the memory therefore 5 will be replaced causing 1 page fault.

Page memory has 3 6 1 pages.

Let come to our question

Page references : 1 3 6 1 3 X 6 3 1

Page memory : 3 6 1

Using (FIFO) : first loaded among the three is 3   therefore 3 will be replaced X.

Using Least recently used: least recently used is six therefor 6 will be replaced with X

Using Optimal algorithm: 6 is not used for longest period among them therefore 6 will be replaced.