Asked By : Sino Ka
Answered By : Wandering Logic
Two-handed clock
By adding a second clock hand to the clock algorithm you get an extremely low-cost approximation of not-recently-used (which is an approximation of least-recently-used.) In the two-handed clock algorithm you have two clock hands. One of the hands is just like before, it points at the next page being considered for replacement. When a replacement is required we just keep moving this clock hand (clearing reference bits) until we find a page with the reference bit cleared, and that’s the page that gets replaced. (So this clock hand is just doing the clock implementation of second chance.) The second clock hand is another pointer into the circularly linked list. The purpose of the second hand is to clear reference bits. Every once in a while you clear the reference bit on the linked-list node that the second hand is pointing to, and set second_hand = second_hand->next. This eliminates one of the problems with second chance, which is that when a page is only used a small amount right after it is first fetched then second-chance will require two cycles through the fifo before that page gets replaced. In the two-handed clock algorithm those “short-term usage” pages get replaced after just one cycle through the fifo. Another replacement algorithm you might look at is WSClock of Carr and Hennessy. It is a combination of the two-handed clock with a bunch of heuristics that are helpful in practice.
Best Answer from StackOverflow
Question Source : http://cs.stackexchange.com/questions/29092