Clock Replacement Policy

What
Clock replacement policy is an implementation of buffer replacement logic inside of buffer management systems inside of most DBMS.

Clock replacement policy relies on the idea of the clock hand, which points to a managed memory frame. The clock hand moves around in a loop and determines which frame to examine for replacement

How
The clock replacement policy revolves on the idea of reference bit. It is the second chance for a frame.
 * 1) When a frame's pin count reaches 0, set the reference bit to on
 * 2) When it's time to choose a frame to replace, we loop through all the frames. If a frame has pin count 0 and has its reference bit on, we turn its reference bit off and continue searching for a page to be replaced. If its reference bit is off, then we choose it to be replaced