Skip to content

Instantly share code, notes, and snippets.

@Jberlinsky
Created November 10, 2012 18:52
Show Gist options
  • Save Jberlinsky/4052113 to your computer and use it in GitHub Desktop.
Save Jberlinsky/4052113 to your computer and use it in GitHub Desktop.
const Status BufMgr::allocBuf(unsigned int & frame)
{
if (numUnpinnedPages() == 0)
return BUFFEREXCEEDED;
while ( 1 ) {
advanceClock(); // advance clock hand
if ( bufTable[clockHand].valid == true ) {
if ( bufTable[clockHand].loved == true ) {
bufTable[clockHand].loved = false;
continue;
}
else if ( bufTable[clockHand].pinCnt > 0 ) {
continue;
}
else if ( bufTable[clockHand].dirty == true) {
flushFile( bufTable[clockHand].file );
}
}
bufTable[clockHand].Clear ();
frame = clockHand;
return OK; // all good
}
}
@anroOfCode
Copy link

This looks all wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment