operating-system-second-chance.html
* created: 2025-06-04T16:46
* modified: 2025-06-30T21:35
title
Second Chance Algorithm
description
The Second Chance Algorithm is an iteration on the FIFO Algorithm which also checks if the page was recently edited.
related notes
Everybody should get a second chance
The Second Chance Algorithm is an iteration on the First In First Out Algorithm. It not only check which is the longest running page, but also if the page was recently accessed.
Checking if a page was recently accessed is done by periodically clearing the R-Bit and checking that.
If the page was recently accessed it will get a Second Chance, and we check if the second-longest running page if it was recently, this can stretch at Infinitum until we find the longest running page that wasn't recently accessed.
What if there isn't a page that was not recently accessed?
Then we fall back to FIFO and just remove the longest running page and hope nothing breaks :).