0 votes 0 votes Answer given is B, but I think it should be D. Stack will pop the least recently used page from the top. How can having most recently used page on top help in LRU implementation? Operating System operating-system paging least-recently-used page-replacement + – Purple asked Nov 29, 2016 Purple 729 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 4 votes 4 votes They are correct. Bottommost page is deleted in stack based replacement algorithm. Top to bottom of a stack represents the recentness of pages in decreasing order. Reference: OS Galvin. Aghori answered Nov 29, 2016 selected Nov 30, 2016 by Purple Aghori comment Share Follow See all 4 Comments See all 4 4 Comments reply Purple commented Nov 30, 2016 reply Follow Share But elements in a stack can only be removed from the top right? In lru using stack it is removing the current page from middle and putting it on top. AFAIK adding and removing in stack is done only from top. Here removing is done from anywhere and adding is done at top. What's the point of calling it a stack then? 1 votes 1 votes Aghori commented Nov 30, 2016 reply Follow Share We leverage at least 2 stacks. To pop bottommost one, we pour elements in another stack & pop topmost. We do so to stop LRU being like FIFO replacement. 1 votes 1 votes Purple commented Nov 30, 2016 reply Follow Share Basically implementation of queue using 2 stacks? 1 votes 1 votes Aghori commented Nov 30, 2016 reply Follow Share Not exactly. We keep updating stack as well. E.g at some time configuration of stack is <2,1,3> (Leftmost is top)After encountering 1 number page configuration changes to <1,2,3> . Here we poured elements into another stack until we get 1. Or like that if not exactly. 1 votes 1 votes Please log in or register to add a comment.