Page replacement algorithm: Difference between revisions

Content deleted Content added
Mxxxr (talk | contribs)
Aging: Make the python code easier to understand
No edit summary
Tags: Reverted possible vandalism
Line 5:
In a [[computer]] [[operating system]] that uses [[memory paging|paging]] for [[virtual memory]] [[memory management|management]], '''page replacement algorithms''' decide which memory pages to page out, sometimes called swap out, or write to disk, when a [[page (computer memory)|page]] of memory needs to be allocated. [[Paging|Page replacement]] happens when a requested page is not in memory ([[page fault]]) and a free page cannot be used to satisfy the allocation, either because there are none, or because the number of free pages is lower than some threshold.
 
When the pagepaig that was selected for replacement and paged out is referenced again it has to be paged in (read in from disk), and this involves waiting for I/O completion. This determines the ''quality'' of the page replacement algorithm: the less time waiting for page-ins, the better the algorithm. A page replacement algorithm looks at the limited information about accesses to the pages provided by hardware, and tries to guess which pages should be replaced to minimize the total number of page misses, while balancing this with the costs (primary storage and processor time) of the algorithm itself.
 
The page replacing problem is a typical [[online problem]] from the competitive analysis perspective in the sense that the optimal deterministic algorithm is known.