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

You have devised a new page-replacement algorithm that you think may be optimal.

ID: 3720318 • Letter: Y

Question

You have devised a new page-replacement algorithm that you think may be optimal. In some test cases, Belady’s anomaly occurs. Is the new algorithm optimal? Explain your answer.

Segmentation is similar to paging but uses variable-sized “pages”.

Define two segment-replacement algorithms based on FIFO and LRU page-replacement schemes for segmentation. Remember that since segments are not the same size, the segment that is chosen to be replaced may not be big enough to leave enough consecutive locations for the needed segment. Consider strategies for systems where segments cannot be relocated, and those for systems where they can.

Explanation / Answer

Answer is as follows:

a)

No, An optimal algorithm will not suffer from Belady’s anomaly because by definition an optimal algorithm replaces the page that will not be used for the longest time. Belady’s anomaly occurs when a page replacement algorithm ejects a page that will be needed in the immediate future. An optimal algorithm would not have selected such a page.

b)

FIFO :

Find the first segment large enough to accommodate the incoming segment. If relocation is not possible and no one segment is large enough, select a combination of segments whose memories are contiguous, which are closest to the first of the list and which can accommodate the new segment. If relocation is possible, rearrange the memory so that the first N segments large enough for the incoming segment are contiguous in memory. Add any leftover space to the free-space list in both cases.

LRU

Select the segment that has not been used for the longest period of time and that is large enough, adding any leftover space to the free space list. If no one segment is large enough, select a combination of the oldest segments that are contiguous in memory where if relocation is not available and that are large enough. If relocation is available, rearrange the oldest N segments to be contiguous in memory and replace those with the new segment.

if there is any query please ask in comments..

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote