Page replacement algorithm: Difference between revisions

Content deleted Content added
Correct minor English phrasing mistakes.
 
(589 intermediate revisions by more than 100 users not shown)
Line 1:
{{Short description|Algorithm for virtual memory implementation}}
In a [[computer]] [[operating system]] which utilises [[paging]] for [[virtual memory]] [[memory management]], '''page replacement algorithms''' decide what pages to page out (swap out) when a page needs to be allocated. That happens when a [[page fault]] occurs and free page cannot be used to satisfy allocation (either because there are none, or because number of free pages is lower than some threshold).
{{about|algorithms specific to paging|an outline of general cache algorithms (e.g. processor, disk, database, web)|Cache algorithms}}
{{Use dmy dates|date=February 2021}}
 
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. 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 page that was selected for replacement and paged out is referenced again it has to be paged in, and this usually involves waiting for I/O completion. This determines the ''quality'' of page replacement algorithm: the less time wasted by waiting for page-ins, the better the algorithm. A page replacement algorithm tries, by looking at the limited information about accesses to the pages provided by hardware, to guess what pages should be replaced in order to minimize total number of page misses, while balancing this with the costs (primary storage and processor time) of algorithm itself.
== History ==
 
When the page 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.
Replacement algorithms were topic of hot research and debate at the [[1960]]s and [[1970]]s.
That mostly ended with the development of sophisticated LRU approximations and working set algorithm. Since then, however, some basic assumptions made by the traditional page replacement algorithms were to some degree invalidated, resulting in revival of research in that area. In particular, following trends in the behavior of underlying hardware and user-level software affected performance of replacement algorithms:
 
The page replacing problem is a typical [[online problem]] from the competitive analysis perspective in the sense that the optimal [[deterministic algorithm]] is known.
* Size of primary storage increased by multiple orders of magnitude. With several gigabytes of primary memory, algorithms that require periodic check of each and every memory frame are becoming less and less practical.
 
== History ==
* Memory hierarchies grew taller. The cost of CPU cache miss is far more expensive. This exacerbates the previous problem.
Page replacement algorithms were a hot topic of research and debate in the 1960s and 1970s.
That mostly ended with the development of sophisticated [[Page replacement algorithm#Least recently used|LRU]] (least recently used) approximations and [[working set]] algorithms. Since then, some basic assumptions made by the traditional page replacement algorithms were invalidated, resulting in a revival of research. In particular, the following trends in the behavior of underlying hardware and user-level software have affected the performance of page replacement algorithms:
 
* Size of primary storage has increased by multiple orders of magnitude. With several gigabytes of primary memory, algorithms that require a periodic check of each and every memory frame are becoming less and less practical.
* [[Memory locality|Locality of reference]] of user software has weakened. This is mostly attributed to the spread of [[Object-oriented programming]] techniques that favor large number of small functions, use of sophisticated data structures like [[Tree data structure |tree]] and [[Hash table]] that tend to chaotic memory reference patterns, and the advent of [[garbage collection (computer science)|garbage collection]] that drastically changed memory access behavior of applications.
* Memory hierarchies have grown taller. The cost of a [[CPU cache]] miss is far more expensive. This exacerbates the previous problem.
* [[Locality of reference]] of user software has weakened. This is mostly attributed to the spread of [[object-oriented programming]] techniques that favor large numbers of small functions, use of sophisticated data structures like [[Tree (data structure)|trees]] and [[hash table]]s that tend to result in chaotic memory reference patterns, and the advent of [[garbage collection (computer science)|garbage collection]] that drastically changed memory access behavior of applications.
 
Also,Requirements requirementsfor to thepage replacement algorithms hashave changed due to the changesdifferences in the operating system [[Kernel (computeroperating sciencesystem)|kernel]] architectures. In particular, most modern OS kernels have unified virtual memory and file system caches., Thisrequiring means,the thatpage replacement algorithm has to deal with selectingselect a target page from among the pages fromof both user program virtual address spaces of user programs and from cached files. The latter pages hashave specific properties. For example, they can be locked, or can have write ordering requirements imposed by [[journallingjournaling file system|journaling]]. Moreover, as the goal of page replacement is to minimize total time wasted by waiting for memory, it has to take into account memory requirements imposed by other kernel sub-systems that allocate memory. As a result, page replacement in modern kernels ([[Linux]], [[FreeBSD]], and [[Solaris (operating system)|Solaris]]) pagetends replacement tendsto work at the level of low-levela general purpose kernel memory allocator, rather than at the higher level of a virtual memory subsystem proper.
 
== Local vs. global replacement ==
Replacement algorithms can be ''local'' or ''global.''
 
When a process incurs a page fault, a local page replacement algorithm selects for replacement some page that belongs to that same process (or a group of processes sharing a [[Memory management (operating systems)#Partitioned allocation|memory partition]]).
Replacement algorithm can be ''local'' or ''global''.
When a process incurs a page fault, a local page replacement algorithm selects for replacement some page that belongs to that same process (or a group of processes sharing memory partition).
A global replacement algorithm is free to select any page in memory.
 
Local page replacement assumes some form of memory partitioning that determines how many pages are to be assigned to a given process ofor a group of processes. Most popular forms of partitioning are ''fixed partitioning'' and ''balancebalanced set'' algorithmalgorithms based on the [[working set]] model. AdvantageThe advantage of local page replacement is its scalability: each process can handle its page faults independently, withoutleading contendingto more consistent performance for somethat sharedprocess. However global datapage structurereplacement is more efficient on an overall system basis.<ref>{{cite web|last1=Bell|first1=John|title=Operating Systems Course Notes: Virtual Memory |url=http://www2.cs.uic.edu/~jbell/CourseNotes/OperatingSystems/9_VirtualMemory.html|website=University of Illinois at Chicago College of Engineering|access-date=21 July 2017|archive-url=https://web.archive.org/web/20180923235717/http://www2.cs.uic.edu/~jbell/CourseNotes/OperatingSystems/9_VirtualMemory.html|archive-date=23 September 2018|url-status=live}}</ref>
 
== Detecting which pages are referenced and modified ==
{{see also|Virtual memory|Page table}}
Modern general purpose computers and some embedded processors have support for [[virtual memory]]. Each process has its own virtual address space. A [[page table]] maps a subset of the process virtual addresses to physical addresses. In addition, in most architectures the page table holds an "access" bit and a "dirty" bit for each page in the page table. The CPU sets the access bit when the process reads or writes memory in that page. The CPU sets the dirty bit when the process writes memory in that page. The operating system can modify the access and dirty bits. The operating system can detect accesses to memory and files through the following means:
* By clearing the access bit in pages present in the process' page table. After some time, the OS scans the page table looking for pages that had the access bit set by the CPU. This is fast because the access bit is set automatically by the CPU and inaccurate because the OS does not immediately receive notice of the access nor does it have information about the order in which the process accessed these pages.
* By removing pages from the process' page table without necessarily removing them from physical memory. The next access to that page is detected immediately because it causes a [[page fault]]. This is slow because a page fault involves a [[context switch]] to the OS, software lookup for the corresponding physical address, modification of the page table and a context switch back to the process and accurate because the access is detected immediately after it occurs.
* Directly when the process makes system calls that potentially access the [[page cache]] like <code>read</code> and <code>write</code> in POSIX.
 
== Precleaning ==
Most replacement algorithms simply return the target page as their result. This means that if target page is ''dirty'' (that is, contains data that have to be written to the stable storage before page can be reclaimed), I/O has to be initiated to send that page to the stable storage (to ''clean'' the page). In the early days of virtual memory, time spent on cleaning was not of much concern, because virtual memory was first implemented on systems with [[full duplex]] channels to the stable storage, and cleaning was customarily overlapped with paging. Contemporary commodity hardware, on the other hand, does not support full duplex transfers, and cleaning of target pages becomes an issue.
 
To deal with this situation, various ''precleaning'' policies are implemented. Precleaning is the mechanism that starts I/O on dirty pages that are (likely) to be replaced soon. The idea is that by the time the precleaned page is actually selected for the replacement, the I/O will complete and the page will be clean. Precleaning assumes that it is possible to identify pages that will be replaced ''next''. Precleaning that is too eager can waste I/O bandwidth by writing pages that manage to get re-dirtied before being selected for replacement.
Most textbook replacement algorithms simply return target page as their result. This means that if target page is ''dirty'' (that is, contains data that have to be written to the stable storage before page can be reclaimed), I/O has to be initiated to send that page to the stable storage (to ''clean'' the page). In the early days of virtual memory, time wasted on cleaning wasn't of much concerns, because virtual memory was first implemented on systems with [[full duplex]] channels to the stable storage, and cleaning was customarily overlapped with pagein. Contemporary commodity hardware, on the other hand, doesn't support full duplex transfers, and cleaning of target pages becomes an issue.
 
==The (h,k)-paging problem==
To deal with it various ''precleaning'' policies are implemented. Precleaning is mechanism that starts I/O on dirty pages that are (likely) to be replaced soon. Idea is that by the time precleaned page is actually selected for the replacement I/O will finish and page will be clean. Precleaning assumes that it is possible to identify pages that will be replaced ''next''. Too eager precleaning can waste I/O bandwidth by writing pages that manage to get re-dirtied before being selected for replacement.
The (h,k)-paging problem is a generalization of the model of paging problem: Let h,k be positive integers such that <math>h \leq k</math>. We measure the performance of an algorithm with cache of size <math>h \leq k</math> relative to [[Page replacement algorithm#The theoretically optimal page replacement algorithm|the theoretically optimal page replacement algorithm]]. If <math>h<k</math>, we provide the optimal page replacement algorithm with strictly less resource.
 
The (h,k)-paging problem is a way to measure how an online algorithm performs by comparing it with the performance of the optimal algorithm, specifically, separately parameterizing the cache size of the online algorithm and optimal algorithm.
== The Theoretically Optimal Page Replacement Algorithm ==
 
==Marking algorithms==
The theoretically optimal page replacement algorithm (also known as OPT or clairvoyant replacement algorithm) is an algorithm which works as follows: when a page needs to be swapped in, the operating system looks at all the pages currently in memory, and sees how long it is before that page will be used. Then, the [[operating system]] swaps out the page which will not be used longest. A page that is not going to be used until 6 million microseconds pass will be swapped out over a page which is going to be used after 4 thousand microseconds.
{{confusing section|date=December 2015}}
 
Marking algorithms is a general class of paging algorithms. For each page, we associate it with a bit called its mark. Initially, we set all pages as unmarked. During a stage (a period of operation or a sequence of requests) of page requests, we mark a page when it is first requested in this stage. A marking algorithm is such an algorithm that never pages out a marked page.
However, this algorithm cannot be implemented in the general purpose operating system, simply because it is not possible or feasible for the operating system to compute how long it is before a page is going to be used, except when all software that will run on a system is either known beforehand and is amendable to the static analysis of its memory reference patterns, or only class of applications allowing run-time analysis is allowed. In spite of this, there exist algorithms which can offer near-optimal performance - on the first run of a program, the operating system keeps track of all the pages which it references, and by using this data, it decides what pages to swap in and out on the second run. This algorithm can offer near-optimal performance, but only on the second run, and only for programs which have been run at least once before, and only if memory reference pattern of program doesn't change significantly between runs.
 
If ALG is a marking algorithm with a cache of size k, and OPT is the optimal algorithm with a cache of size h, where <math>h \leq k</math>, then ALG is <math> \tfrac{k}{k-h+1}</math>-competitive. So every marking algorithm attains the <math> \tfrac{k}{k-h+1}</math>-competitive ratio.
== Not Recently Used ==
 
LRU is a marking algorithm while FIFO is not a marking algorithm.
The not recently used (NRU) page replacement algorithm is an algorithm which favours keeping pages which have been recently used. This algorithm works on the following principle: when a page is referenced, a referenced bit will be set for that page, marking it as referenced. Similarly, when a page is modified (written to), a modified bit will be set. The setting of the bits is usually done by the hardware, although it is possible to do so on the software level as well.
 
==Conservative algorithms==
At a certain fixedtime interval, the clock interrupt triggers and clears the referenced bit of all the pages, so only pages referenced within the current clock interval are marked with a referenced bit. When a page needs to be replaced, the [[operating system]] divides the pages into four categories:
An algorithm is conservative, if on any consecutive request sequence containing k or fewer distinct page references, the algorithm will incur k or fewer page faults.
 
If ALG is a conservative algorithm with a cache of size k, and OPT is the optimal algorithm with a cache of <math>h \leq k</math>, then ALG is <math> \tfrac{k}{k-h+1}</math>-competitive. So every conservative algorithm attains the <math> \tfrac{k}{k-h+1}</math>-competitive ratio.
*Category 0: not referenced, not modified
*Category 1: not referenced, modified
*Category 2: referenced, not modified
*Category 3: referenced, modified
 
LRU, FIFO and CLOCK are conservative algorithms.
Although it does not seem possible for a page to be not referenced yet modified, this happens when a category 3 page has its referenced bit cleared by the clock interrupt. The NRU algorithm simply picks a random page from the lowest category for removal. Note that this algorithm implies that a referenced page is more important than a modified page.
 
==Page replacement algorithms==
== First-In First-Out ==
There are a variety of page replacement algorithms:<ref name='lecture notes jones'/>
 
===The theoretically optimal page replacement algorithm===
The first-in first-out (FIFO) page replacement algorithm is another low-overhead algorithm which requires little bookkeeping on the part of the [[operating system]]. The idea is obvious from the name - the operating system keeps track of all the pages in memory in a queue, with the most recent arrival at the back, and the earliest arrival in front. When a page needs to be replaced, the page at the front of the queue is selected, as it will be the oldest page. While FIFO is cheap and intuitive, it performs relatively badly in practical application. Thus, it is rarely used in its unmodified form.
The theoretically optimal page replacement algorithm (also known as OPT, [[Clairvoyance|clairvoyant]] replacement algorithm, or [[László Bélády|Bélády's]] optimal page replacement policy)<ref>{{cite web|url=http://www.read.cs.ucla.edu/111/2006fall/notes/lec11|title=CS111 Lecture 11 notes|archive-url=https://web.archive.org/web/20090109175934/http://www.read.cs.ucla.edu/111/2006fall/notes/lec11|archive-date=9 January 2009|last1=Torrez|first1=Paul|last2=Hallner|first2=Tim|last3=Mathrani|first3=Kiran|last4=Bhaskar|first4=Anu|display-authors=1|url-status=dead|website=UCLA Computer Science Department}}</ref><ref>{{cite conference |title=Characterization of Web reference behavior revisited: Evidence for Dichotomized Cache management |first1=Hyokyung |last1=Bahn |last2=Noh |first2=Sam H. |date=12-14 February 2003 |conference=International Conference on Information Networking 2003 |conference-url=https://link.springer.com/book/10.1007/b13389 |publisher=Springer-Verlag |___location=Jeju, South Korea |pages=1018–1027 |isbn=978-3-540-40827-7 |doi=10.1007/978-3-540-45235-5_100 |language=en}}</ref><ref name='lecture notes jones'>{{cite web|last1=Jones|first1=Douglas W.|website=University of Iowa Department of Computer Science|url=http://www.cs.uiowa.edu/~jones/opsys/fall95/notes/0908.html|title=22C:116 Lecture Notes|archive-url=https://archive.today/20120630230917/http://homepage.cs.uiowa.edu/~jones/opsys/fall95/notes/0908.html|archive-date=30 June 2012|url-status=live|access-date=18 March 2008}}</ref> is an algorithm that works as follows: when a page needs to be swapped in, the [[operating system]] swaps out the page whose next use will occur farthest in the future. For example, a page that is not going to be used for the next 6 seconds will be swapped out over a page that is going to be used within the next 0.4 seconds.
 
This algorithm cannot be implemented in a general purpose operating system because it is impossible to compute reliably how long it will be before a page is going to be used, except when all software that will run on a system is either known beforehand and is amenable to static analysis of its memory reference patterns, or only a class of applications allowing run-time analysis. Despite this limitation, algorithms exist<ref>{{cite conference |title=Back to the Future: Leveraging Belady's Algorithm for Improved Cache Replacement |first1=Akanksha |last1=Jain |first2=Calvin |last2=Lin |date=2016 |conference=International Symposium on Computer Architecture (ISCA) |publisher=IEEE |___location=Seoul, South Korea |doi=10.1109/ISCA.2016.17 |language=en |url=https://www.cs.utexas.edu/~lin/papers/isca16.pdf}}</ref> that can offer near-optimal performance —<!-- on the first run of a program, (conflicts with following sentense) --> the operating system keeps track of all pages referenced by the program, and it uses those data to decide which pages to swap in and out on subsequent runs. This algorithm can offer near-optimal performance, but not on the first run of a program, and only if the program's memory reference pattern is relatively consistent each time it runs.
FIFO page replacement algorithm is used by the [[VAX/VMS]] operating system.
 
Analysis of the paging problem has also been done in the field of [[online algorithm]]s. Efficiency of randomized online algorithms for the paging problem is measured using [[amortized analysis]].
== Second-Chance ==
 
===Not recently used===
A modified form of the FIFO page replacement algorithm, known as the second chance page replacement algorithm, fares relatively better than FIFO at little cost for the improvement. It works by looking at the front of the queue as FIFO does, but instead of immediately swapping out that page, it checks to see if its referenced bit is set. If it is not set, the page is swapped out. Otherwise, the referenced bit is cleared, and the page is inserted at the back of the queue, as if it were a new page, and this process is repeated. If all the pages have their referenced bit set, on the second encounter of the first page in the list, that page will be swapped out, as it now has its referenced bit cleared.
The not recently used (NRU) page replacement algorithm is an algorithm that favours keeping pages in memory that have been recently used. This algorithm works on the following principle: when a page is referenced, a referenced bit is set for that page, marking it as referenced. Similarly, when a page is modified (written to), a modified bit is set. The setting of the bits is usually done by the hardware, although it is possible to do so on the software level as well.
 
At a certain fixed time interval, a timer interrupt triggers and clears the referenced bit of all the pages, so only pages referenced within the current timer interval are marked with a referenced bit. When a page needs to be replaced, the [[operating system]] divides the pages into four classes:
Essentially, what second-chance does is, as its name suggests, giving every page a "second-chance" - an old page which has been referenced is probably in use, and should not be swapped out over a new page which has not been referenced.
<br />
:3. referenced, modified
:2. referenced, not modified
:1. not referenced, modified
:0. not referenced, not modified
Although it does not seem possible for a page to be modified yet not referenced, this happens when a class 3 page has its referenced bit cleared by the timer interrupt. The NRU algorithm picks a random page from the lowest category for removal. So out of the above four page categories, the NRU algorithm will replace a not-referenced, not-modified page if such a page exists. Note that this algorithm implies that a modified but not-referenced (within the last timer interval) page is less important than a not-modified page that is intensely referenced.
 
NRU is a marking algorithm, so it is <math> \tfrac{k}{k-h+1}</math>-competitive.
== Least Recently Used ==
 
===First-in, first-out===
The least recently used page (LRU) replacement algorithm, though similar in name to NRU, differs in the fact that LRU keeps track of page usage over a short period of time, while NRU just looks at the usage in the last clock interval. LRU works on the idea that the pages which have been most heavily used in the past few instructions will be used heavily in the next few instructions too. While LRU can provide near-optimal performance in theory, it is rather expensive to implement in practice. There are a few implementation methods for this algorithm which try to reduce the cost yet keep as much of the performance as possible.
The simplest page-replacement algorithm is a FIFO algorithm. The first-in, first-out (FIFO) page replacement algorithm is a low-overhead algorithm that requires little bookkeeping on the part of the [[operating system]]. The idea is obvious from the name – the operating system keeps track of all the pages in memory in a queue, with the most recent arrival at the back, and the oldest arrival in front. When a page needs to be replaced, the page at the front of the queue (the oldest page) is selected. While FIFO is cheap and intuitive, it performs poorly in practical application. Thus, it is rarely used in its unmodified form. This algorithm experiences [[Bélády's anomaly]].
In simple words, on a page fault, the frame that has been in memory the longest is replaced.
 
FIFO page replacement algorithm is used by the [[OpenVMS]] operating system, with some modifications.<ref name="Silber">{{Cite book|language=en|title=Operating system concepts|last1=Silberschatz|first1=Abraham|date=14 December 2004|publisher=John Wiley & Sons|last2=Galvin|first2=Peter Baer|last3=Gagne|first3=Greg|isbn=0-47169-466-5|edition=7th|page=339|___location=Hoboken, NJ, USA|oclc=56913661}}</ref> Partial second chance is provided by skipping a limited number of entries with valid translation table references,<ref>[http://mx.isti.cnr.it/cgi-bin/conan?key=Sys_Parameters~TBSKIPWSL&title=VMS%20Help VMS Help — Sys Parameters, TBSKIPWSL]{{Dead link|date=July 2025 |bot=InternetArchiveBot |fix-attempted=yes }}</ref> and additionally, pages are displaced from process working set to a systemwide pool from which they can be recovered if not already re-used.
The most expensive method is the linked list method, whereby there is a linked list containing all the pages in memory. At the back of this list is the least recently used page, and at the front is the most recently used page. The cost of this implementation lies in the fact that items in the list will have to be moved about every memory reference, which is a very time-consuming process.
 
FIFO is a conservative algorithm, so it is <math> \tfrac{k}{k-h+1}</math>-competitive.
Another way, which requires hardware support is as follows: suppose the hardware has a 64-bit counter which is incremented at every instruction. Whenever a page is accessed, it gains a value equal to the counter at the time of page access. Whenever a page needs to be replaced, the [[operating system]] simply picks out the page which has the lowest counter, and swaps it out. This is not feasible in present hardware as there exists no such hardware counters.
 
===Second-chance===
Because of these implementation costs, one may consider algorithms, such as those which follow, which are similar to LRU, but which offer cheaper implementations.
A modified form of the FIFO page replacement algorithm, known as the Second-chance page replacement algorithm, fares relatively better than FIFO at little cost for the improvement. It works by looking at the front of the queue as FIFO does, but instead of immediately paging out that page, it checks to see if its referenced bit is set. If it is not set, the page is swapped out. Otherwise, the referenced bit is cleared, the page is inserted at the back of the queue (as if it were a new page) and this process is repeated. This can also be thought of as a circular queue. If all the pages have their referenced bit set, on the second encounter of the first page in the list, that page will be swapped out, as it now has its referenced bit cleared. If all the pages have their reference bit cleared, then second chance algorithm degenerates into pure FIFO.
 
As its name suggests, Second-chance gives every page a "second-chance" – an old page that has been referenced is probably in use, and should not be swapped out over a new page that has not been referenced.
One important advantage of LRU algorithm is that it is amendable to the full statistical analysis. It has been proved, for example, that LRU can never result in more than N-times more page faults than OPT algorithm, where N is proportional to the number of pages in the managed pool.
 
===Clock===
On the other hand, LRU weakness is that its performance tends to degenerate under many quite common reference patterns. For example, if there are N pages in the LRU pool, then application doing loop over array of N + 1 pages will cause page fault on each and every access. As loops over large arrays are extremely common a lot of effort was put into modifying LRU to work better in such situations. Many of proposed LRU modifications try to detect looping reference pattern and to switch into suitable replacement algorithm, like Most Recently Used (MRU).
Clock is a more efficient version of FIFO than Second-chance because pages don't have to be constantly pushed to the back of the list, but it performs the same general function as Second-Chance. The clock algorithm keeps a circular list of pages in memory, with the "hand" (iterator) pointing to the last examined page frame in the list. When a page fault occurs and no empty frames exist, then the R (referenced) bit is inspected at the hand's ___location. If R is 0, the new page is put in place of the page the "hand" points to, and the hand is advanced one position. Otherwise, the R bit is cleared, then the clock hand is incremented and the process is repeated until a page is replaced.<ref name="Tanenbaum">{{cite book |first=Andrew S. |last=Tanenbaum |date=2001 |title=Modern Operating Systems |edition=2nd |publisher=Prentice-Hall |___location=Upper Saddle River, NJ, USA |isbn=978-0-13-031358-4 |lccn=00051666 |ol=24214243M |oclc=45284637 |page=[https://archive.org/details/modernoperatings00tane/page/218 218 (4.4.5)] |url=https://archive.org/details/modernoperatings00tane/page/218 }}</ref> This algorithm was first described in 1969 by [[Fernando J. Corbató]].<ref>{{cite book|title=Festschrift: In Honor of P. M. Morse|chapter=A Paging Experiment with the Multics System|chapter-url=https://www.multicians.org/paging-experiment.pdf|last1=Corbató|first1=Fernando J.|year=1969|pages=217–228|publisher=[[MIT Press]]}}</ref>
 
====Variants Randomof clock====
* GCLOCK: Generalized clock page replacement algorithm.<ref>{{cite journal|last1=Smith|first1=Alan Jay|title=Sequentiality and prefetching in database systems|journal=ACM Transactions on Database Systems|volume=3|issue=3|pages=223–247|date=September 1978|doi=10.1145/320263.320276|publisher=ACM|language=en|___location=New York, NY, USA|s2cid=11611563|doi-access=free}}</ref>
* Clock-Pro keeps a circular list of information about recently referenced pages, including all M pages in memory as well as the most recent M pages that have been paged out. This extra information on paged-out pages, like the similar information maintained by [[adaptive replacement cache|ARC]], helps it work better than LRU on large loops and one-time scans.<ref>{{cite conference |first2=Feng |last2=Chen |url=http://www.cse.ohio-state.edu/hpcs/WWW/HTML/publications/papers/TR-05-3.pdf |title=CLOCK-Pro: an effective improvement of the CLOCK replacement |first3=Xiaodong |last3=Zhang |first1=Song |last1=Jiang |date=10-15 April 2005 |conference=2005 USENIX Annual Technical Conference |conference-url=https://www.usenix.org/conference/2005usenixannualtechnicalconference |publisher=USENIX Association |archive-url=http://archive.wikiwix.com/cache/20190612095142/http://www.cse.ohio-state.edu/hpcs/WWW/HTML/publications/papers/TR-05-3.pdf |archive-date=12 June 2019 |___location=Anaheim, CA, USA |page=35 |url-status=live |language=en |access-date=24 March 2009 }}</ref>
* WSclock.<ref>{{cite conference |first2=John L. |last2=Hennessy |url=http://infolab.stanford.edu/~manku/quals/zpapers/81-wsclock.pdf.gz |title=WSCLOCK—a simple and effective algorithm for virtual memory management |format=gzipped PDF |first1=Richard W. |last1=Carr |date=14-16 December 1981 |conference=Eighth ACM symposium on Operating systems principles |conference-url=https://dl.acm.org/citation.cfm?doid=800216 |publisher=ACM |archive-url=https://web.archive.org/web/20070610070838/http://infolab.stanford.edu/~manku/quals/zpapers/81-wsclock.pdf.gz |archive-date=10 June 2007 |___location=Pacific Grove, CA, USA |pages=87–95 |url-status=live |language=en |isbn=0-89791-062-1 |doi=10.1145/800216.806596}}</ref> By combining the Clock algorithm with the concept of a working set (i.e., the set of pages expected to be used by that process during some time interval), the performance of the algorithm can be improved. In practice, the "aging" algorithm and the "WSClock" algorithm are probably the most important page replacement algorithms.<ref>{{cite web|last1=Gottlieb|first1=Allan|title=WSClock|url=http://www.cs.nyu.edu/courses/spring09/V22.0202-002/wsclock-davis.html|website=New York University Computer Science Department|access-date=12 June 2019|archive-url=https://archive.today/20120730042750/http://www.cs.nyu.edu/courses/spring09/V22.0202-002/wsclock-davis.html|archive-date=30 July 2012|url-status=live}}</ref><ref>{{cite web|last1=Tanenbaum|first1=Andrew S.|title=Page Replacement Algorithms|url=http://www.informit.com/articles/article.aspx?p=25260&seqNum=11|website=InformIT|access-date=12 June 2019|archive-url=https://archive.today/20120910015221/http://www.informit.com/articles/article.aspx?p=25260&seqNum=11|archive-date=10 September 2012|url-status=live}}</ref>
* Clock with Adaptive Replacement (CAR) is a page replacement algorithm that has performance comparable to [[Adaptive replacement cache|ARC]], and substantially outperforms both LRU and CLOCK.<ref>{{cite conference |first2=Dharmendra S. |last2=Modha |name-list-style=amp |url=http://usenix.org/publications/library/proceedings/fast04/tech/full_papers/bansal/bansal.pdf |title=CAR: Clock with Adaptive Replacement |first1=Sorav |last1=Bansal |date=31 March – 2 April 2004 |conference=3rd USENIX Conference on File and Storage Technologies (FAST '04) |conference-url=https://www.usenix.org/conference/fast04 |publisher=USENIX Association |archive-url=https://web.archive.org/web/20040731112559/http://www.almaden.ibm.com/cs/people/dmodha/clockfast.pdf |archive-date=31 July 2004| url-status=live |___location=San Francisco, CA, USA |pages=187–200 |language=en |citeseerx=10.1.1.105.6057}}</ref> The algorithm CAR is self-tuning and requires no user-specified magic parameters.
 
CLOCK is a conservative algorithm, so it is <math> \tfrac{k}{k-h+1}</math>-competitive.
Random replacement algorithm replaces random page in memory. However silly that may sound, this algorithm is useful in certain situations. Usually it fares better than FIFO, and for looping memory references it is better than LRU. [[OS/390]] uses global LRU approximation and falls back to random replacement when LRU performance degenerates.
 
===Least recently used===
== Not Frequently Used ==
The least recently used (LRU) page replacement algorithm, though similar in name to NRU, differs in the fact that LRU keeps track of page usage over a short period of time, while NRU just looks at the usage in the last clock interval. LRU works on the idea that pages that have been most heavily used in the past few instructions are most likely to be used heavily in the next few instructions too. While LRU can provide near-optimal performance in theory (almost as good as [[adaptive replacement cache]]), it is rather expensive to implement in practice. There are a few implementation methods for this algorithm that try to reduce the cost yet keep as much of the performance as possible.
 
The most expensive method is the linked list method, which uses a linked list containing all the pages in memory. At the back of this list is the least recently used page, and at the front is the most recently used page. The cost of this implementation lies in the fact that items in the list will have to be moved about every memory reference, which is a very time-consuming process.
The not frequently used (NFU) page replacement algorithm also requires a counter, but every page has one counter of its own, which is initially zero. At each clock interval, all pages which have been referenced within that interval will have their counter incremented by 1. In effect, the counters keep track of how frequently a page has been used. Thus, the page with the lowest counter can be swapped out when necessary.
 
Another method that requires hardware support is as follows: suppose the hardware has a 64-bit counter that is incremented at every instruction. Whenever a page is accessed, it acquires the value equal to the counter at the time of page access. Whenever a page needs to be replaced, the [[operating system]] selects the page with the lowest counter and swaps it out.
 
Because of implementation costs, one may consider algorithms (like those that follow) that are similar to LRU, but which offer cheaper implementations.
 
One important advantage of the LRU algorithm is that it is amenable to full statistical analysis. It has been proven, for example, that LRU can never result in more than N-times more page faults than OPT algorithm, where N is proportional to the number of pages in the managed pool.
 
On the other hand, LRU's weakness is that its performance tends to degenerate under many quite common reference patterns. For example, if there are N pages in the LRU pool, an application executing a loop over array of N + 1 pages will cause a page fault on each and every access. As loops over large arrays are common, much effort has been put into modifying LRU to work better in such situations. Many of the proposed LRU modifications try to detect looping reference patterns and to switch into suitable replacement algorithm, like Most Recently Used (MRU).
 
====Variants on LRU====
# LRU-K<ref>{{cite conference |first2=Patrick E. |last2=O'Neil |url=https://www.cs.cmu.edu/~christos/courses/721-resources/p297-o_neil.pdf |title=The LRU-K page replacement algorithm for database disk buffering |first1=Elizabeth J. |last1=O'Neil |date=25-28 May 1993 |conference=1993 ACM SIGMOD international conference on Management of data |conference-url=https://dl.acm.org/citation.cfm?id=170035 |publisher=ACM |___location=Washington, D.C., USA |pages=297–306 |url-status=live |language=en |isbn=0-89791-592-5 |doi=10.1145/170035.170081 |display-authors=1 |last3=Weikum |first3=Gerhard |archive-url=http://archive.wikiwix.com/cache/20190906015742/https://www.cs.cmu.edu/~christos/courses/721-resources/p297-o_neil.pdf |archive-date=6 September 2019 |citeseerx=10.1.1.18.1434}}</ref> evicts the page whose K-th most recent access is furthest in the past. For example, LRU-1 is simply LRU whereas LRU-2 evicts pages according to the time of their penultimate access. LRU-K improves greatly on LRU with regards to locality in time.
# The [[Adaptive replacement cache|ARC]]<ref>{{cite conference |first2=Dharmendra S. |last2=Modha |name-list-style=amp |url=http://www.usenix.org/events/fast03/tech/full_papers/megiddo/megiddo.pdf |title=ARC: A Self-Tuning, Low Overhead Replacement Cache |first1=Nimrod |last1=Megiddo |date=31 March – 2 April 2003 |conference=2nd USENIX Conference on File and Storage Technologies (FAST '03) |conference-url=https://www.usenix.org/conference/fast03 |publisher=USENIX Association |archive-url=https://web.archive.org/web/20100208162647/http://www.almaden.ibm.com/cs/people/dmodha/arcfast.pdf |archive-date=8 February 2010 |url-status=live |___location=San Francisco, CA, USA |pages=115–130 |language=en}}</ref> algorithm extends LRU by maintaining a history of recently evicted pages and uses this to change preference to recent or frequent access. It is particularly resistant to sequential scans.
# The 2Q<ref>{{cite conference |first2=Dennis |last2=Shasha |url=http://www.vldb.org/conf/1994/P439.PDF |title=2Q: A Low Overhead High Performance Buffer Management Replacement Algorithm |first1=Theodore |last1=Johnson |date=12-15 September 1994 |conference=20th International Conference on Very Large Data Bases |conference-url=https://dblp.org/db/conf/vldb/vldb94 |publisher=Morgan Kaufmann |archive-url=http://archive.wikiwix.com/cache/20200317170617/http://www.vldb.org/conf/1994/P439.PDF |archive-date=17 March 2020 |___location=Santiago de Chile, Chile |pages=439–450 |isbn=1-55860-153-8 |url-status=live |language=en |access-date=31 July 2005 }}</ref> algorithm improves upon the LRU and LRU/2 algorithm. By having two queues, one for hot-path items and the other for slow-path items, items are first placed in the slow-path queue and after a second access of the items placed in the hot-path items. Because references to added items are longer hold than in the LRU and LRU/2 algorithm, it has a better hot-path queue which improves the hit rate of the cache.
 
A comparison of ARC with other algorithms (LRU, MQ, 2Q, LRU-2, LRFU, [[LIRS caching algorithm|LIRS]]) can be found in Megiddo & Modha 2004.<ref>{{cite journal|last1=Megiddo|first1=Nimrod|last2=Modha|first2=Dharmendra S.|name-list-style=amp|url=http://dbs.uni-leipzig.de/file/ARC.pdf|title=Outperforming LRU with an Adaptive Replacement Cache Algorithm|doi=10.1109/MC.2004.1297303|year=2004|journal=Computer|volume=37|issue=4|pages=58|citeseerx=10.1.1.231.498|archive-url=http://archive.wikiwix.com/cache/20121021000000/http://dbs.uni-leipzig.de/file/ARC.pdf|archive-date=21 October 2012|publisher=IEEE Computer Society|s2cid=5507282|url-status=live|access-date=20 September 2013}}</ref>
 
LRU is a marking algorithm, so it is <math> \tfrac{k}{k-h+1}</math>-competitive.
 
===Random===
Random replacement algorithm replaces a random page in memory. This eliminates the overhead cost of tracking page references. Usually it fares better than FIFO, and for looping memory references it is better than LRU, although generally LRU performs better in practice. [[OS/390]] uses global LRU approximation and falls back to random replacement when LRU performance degenerates, and the [[Intel i860]] processor used a random replacement policy (Rhodehamel 1989<ref>{{cite conference |title=The Bus Interface and Paging Units of the i860 Microprocessor |first=Michael W. |last=Rhodehamel |date=2-4 October 1989 |conference=1989 IEEE International Conference on Computer Design: VLSI in Computers and Processors |conference-url=https://ieeexplore.ieee.org/xpl/mostRecentIssue.jsp?punumber=257 |publisher=IEEE |___location=Cambridge, MA, USA |pages=380–384 |isbn=0-8186-1971-6 |doi=10.1109/ICCD.1989.63392 |language=en |id=INSPEC Accession Number 3719504}}</ref>).
 
===Not frequently used (NFU)===
The not frequently used (NFU) page replacement algorithm requires a counter, and every page has one counter of its own which is initially set to 0. At each clock interval, all pages that have been referenced within that interval will have their counter incremented by 1. In effect, the counters keep track of how frequently a page has been used. Thus, the page with the lowest counter can be swapped out when necessary.
 
The main problem with NFU is that it keeps track of the frequency of use without regard to the time span of use. Thus, in a multi-pass compiler, pages which were heavily used during the first pass, but are not needed in the second pass will be favoured over pages which are comparably lightly used in the second pass, as they have higher frequency counters. This results in poor performance. Other common scenarios exist where NFU will perform similarly, such as an OS boot-up. Thankfully, a similar and better algorithm exists, and its description follows.
 
The not frequently used page-replacement algorithm generates fewer page faults than the least recently used page replacement algorithm when the page table contains null pointer values.
== Aging ==
 
===Aging===
The aging algorithm is a descendant of the NFU algorithm, with modifications to make it aware of the time span of use. Instead of just incrementing the counters of pages referenced, putting equal emphasis on page references regardless of the time, the reference counter on a page is first shifted right (divided by 2), before adding the referenced bit to the left of that binary number. For instance, if a page has referenced bits 1,0,0,1,1,0 in the past 6 clock ticks, its referenced counter will look like this: 10000000, 01000000, 00100000, 10010000, 11001000, 01100100. As you can see, page references closer to the present have more impact than page references a long time ago in the past. This ensures that pages referenced more recently, though less frequently referenced, will have higher priority over pages more frequently referenced in the past. Thus, when a page needs to be swapped out, the page with the lowest counter will be chosen.
The aging algorithm is a descendant of the NFU algorithm, with modifications to make it aware of the time span of use. Instead of just incrementing the counters of pages referenced, putting equal emphasis on page references regardless of the time, the reference counter on a page is first shifted right (divided by 2), before adding the referenced bit to the left of that binary number. For instance, if a page has referenced bits 1,0,0,1,1,0 in the past 6 clock ticks, its referenced counter will look like this in chronological order: 10000000, 01000000, 00100000, 10010000, 11001000, 01100100. Page references closer to the present time have more impact than page references long ago. This ensures that pages referenced more recently, though less frequently referenced, will have higher priority over pages more frequently referenced in the past. Thus, when a page needs to be swapped out, the page with the lowest counter will be chosen.
 
The following [[Python (programming language)|Python]] code simulates the aging algorithm.
Note that aging differs from LRU in the sense that aging can only keep track of the references in the latest 16/32 (depending on the bit size of the processor's integers) time intervals. Consequently, two pages may have referenced counters of 00000000, even though one page was referenced 9 intervals ago and the other 1000 intervals ago. Generally speaking, knowing the usage within the past 16 intervals is sufficient for making a good decision as to which page to swap out. Thus, aging can offer near-optimal performance for a moderate price.
Counters <math>V_i</math> are initialized with {{val|0}} and updated as described above via <math>V_i \leftarrow (R_i \ll (k-1)) | (V_i \gg 1)</math>, using [[Arithmetic shift|arithmetic shift operators]].
<syntaxhighlight lang="python">
from collections.abc import Sequence
 
def simulate_aging(Rs: Sequence, k: int) -> None:
== References ==
"""Simulate aging"""
print(" t | R-bits (0-{length}) | Counters for pages 0-{length}".format(length=len(Rs)))
Vs = [0] * len(Rs[0])
for t, R in enumerate(Rs):
Vs[:] = [R[i] << (k - 1) | V >> 1 for i, V in enumerate(Vs)]
print("{:02d} | {} | [{}]".format(t, R,
", ".join(["{:0{}b}".format(V, k)
for V in Vs])))
</syntaxhighlight>
In the given example of R-bits for 6 pages over 5 clock ticks, the function prints the following output, which lists the R-bits for each clock tick {{mvar|t}} and the individual counter values <math>V_i</math> for each page in [[Binary number|binary]] representation.<ref>{{cite book |first1=Andrew S. |last1=Tanenbaum |first2=Herbert |last2=Bos |date=2015 |title=Modern Operating Systems |edition=4th |publisher=Pearson |___location=Boston, MA, USA |page=215 |isbn=978-0-13-359162-0 |ol=25620855M}}</ref>
<syntaxhighlight lang="pycon">
>>> Rs = [[1,0,1,0,1,1], [1,1,0,0,1,0], [1,1,0,1,0,1], [1,0,0,0,1,0], [0,1,1,0,0,0]]
>>> k = 8
>>> simulate_aging(Rs, k)
t | R-bits (0-5) | Counters for pages 0-5
00 | [1, 0, 1, 0, 1, 1] | [10000000, 00000000, 10000000, 00000000, 10000000, 10000000]
01 | [1, 1, 0, 0, 1, 0] | [11000000, 10000000, 01000000, 00000000, 11000000, 01000000]
02 | [1, 1, 0, 1, 0, 1] | [11100000, 11000000, 00100000, 10000000, 01100000, 10100000]
03 | [1, 0, 0, 0, 1, 0] | [11110000, 01100000, 00010000, 01000000, 10110000, 01010000]
04 | [0, 1, 1, 0, 0, 0] | [01111000, 10110000, 10001000, 00100000, 01011000, 00101000]
</syntaxhighlight>
 
Note that aging differs from LRU in the sense that aging can only keep track of the references in the latest {{val|16|/|32}} (depending on the bit size of the processor's integers) time intervals. Consequently, two pages may have referenced counters of 00000000, even though one page was referenced 9 intervals ago and the other 1000 intervals ago. Generally speaking, knowing the usage within the past 16 intervals is sufficient for making a good decision as to which page to swap out. Thus, aging can offer near-optimal performance for a moderate price.
* Tanenbaum, Andrew S. ''Operating Systems: Design and Implementation (Second Edition)''. New Jersey: Prentice-Hall 1997.
 
*===Longest [http://www.vldb.org/conf/1994/P439.PDFdistance 2Qfirst (LDF) page replacement algorithm]===
The basic idea behind this algorithm is Locality of Reference as used in LRU but the difference is that in LDF, locality is based on distance not on the used references. In the LDF, replace the page which is on longest distance from the current page. If two pages are on same distance then the page which is next to current page in anti-clock rotation will get replaced.{{cn|date=July 2022}}
 
== Implementation details ==
* [http://citeseer.ist.psu.edu/cache/papers/cs/1905/http:zSzzSzwww.cs.wisc.eduzSz~caozSzpaperszSzpfpaper.ps.gz/glass97adaptive.ps.gz Adaptive-Page-Replacement-Based-on-Memory-Reference-Behavior]
 
===Techniques for hardware with no reference bit===
* [http://www.almaden.ibm.com/cs/people/dmodha/arcfast.pdf ARC: A Self-tuning, low overhead replacement cache]
Many of the techniques discussed above assume the presence of a reference bit associated with each page. Some hardware has no such bit, so its efficient use requires techniques that operate well without one.
 
One notable example is [[VAX]] hardware running [[OpenVMS]]. This system knows if a page has been modified, but not necessarily if a page has been read. Its approach is known as Secondary Page Caching. Pages removed from working sets (process-private memory, generally) are placed on special-purpose lists while remaining in physical memory for some time. Removing a page from a working set is not technically a page-replacement operation, but effectively identifies that page as a candidate. A page whose backing store is still valid (whose contents are not dirty, or otherwise do not need to be preserved) is placed on the tail of the Free Page List. A page that requires writing to backing store will be placed on the Modified Page List. These actions are typically triggered when the size of the Free Page List falls below an adjustable threshold.
* [http://citeseer.ist.psu.edu/kim00lowoverhead.html A Low-Overhead High-Performance Unified Buffer Management Scheme that Exploits Sequential and Looping References]
 
Pages may be selected for working set removal in an essentially random fashion, with the expectation that if a poor choice is made, a future reference may retrieve that page from the Free or Modified list before it is removed from physical memory. A page referenced this way will be removed from the Free or Modified list and placed back into a process working set. The Modified Page List additionally provides an opportunity to write pages out to backing store in groups of more than one page, increasing efficiency. These pages can then be placed on the Free Page List. The sequence of pages that works its way to the head of the Free Page List resembles the results of a LRU or NRU mechanism and the overall effect has similarities to the Second-Chance algorithm described earlier.
* [http://www.almaden.ibm.com/cs/people/dmodha/clockfast.pdf CAR: Clock with Adaptive Replacement]
 
Another example is used by the [[Linux kernel]] on [[ARM architecture family|ARM]]. The lack of hardware functionality is made up for by providing two page tables – the processor-native page tables, with neither referenced bits nor [[dirty bit]]s, and software-maintained page tables with the required bits present. The emulated bits in the software-maintained table are set by page faults. In order to get the page faults, clearing emulated bits in the second table revokes some of the access rights to the corresponding page, which is implemented by altering the native table.
* [http://www.cs.amherst.edu/~sfkaplan/courses/spring-2004/cs40/papers/SKW:EELRUSEAPR.pdf EELRU: Simple and Effective Adaptive Page Replacement]
 
=== Page cache in Linux ===
* [http://www.cs.wm.edu/hpcs/WWW/HTML/publications/papers/TR-02-6.pdf LIRS: a Low Inter Reference recency Set replacement]
[[Linux kernel|Linux]] uses a unified page cache for
* [[sbrk|<code>brk</code>]] and anonymous [[mmap|<code>mmap</code>]]ed-regions. This includes the [[heap (programming)|heap]] and [[stack-based memory allocation|stack]] of [[user space and kernel space|user-space]] programs. It is written to swap when paged out.
* Non-anonymous (file-backed) <code>mmap</code>ed regions. If present in memory and not privately modified the physical page is shared with file cache or buffer.
* Shared memory acquired through [[shared memory#Support on Unix-like systems|<code>shm_open</code>]].
* The [[tmpfs]] in-memory filesystem; written to swap when paged out.
* The file cache including; written to the underlying block storage (possibly going through the buffer, see below) when paged out.
* The cache of [[block device]]s, called the "buffer" by Linux (not to be confused with other structures also called buffers like those use for [[anonymous pipe|pipes]] and buffers used internally in Linux); written to the underlying storage when paged out.
The unified page cache operates on units of the smallest page size supported by the CPU (4&nbsp;KiB in [[ARMv8]], [[x86]] and [[x86-64]]) with some pages of the next larger size (2 MiB in [[x86-64]]) called "huge pages" by Linux. The pages in the page cache are divided in an "active" set and an "inactive" set. Both sets keep a LRU list of pages. In the basic case, when a page is accessed by a user-space program it is put in the head of the inactive set. When it is accessed repeatedly, it is moved to the active list. Linux moves the pages from the active set to the inactive set as needed so that the active set is smaller than the inactive set. When a page is moved to the inactive set it is removed from the page table of any process address space, without being paged out of physical memory.<ref>See explanation at the start of [https://github.com/torvalds/linux/blob/master/mm/workingset.c <code>/mm/workingset.c</code>] in the Linux source</ref><ref>{{cite news|last1=Corbet|first1=Jonathan Corbet|title=Better active/inactive list balancing|url=https://lwn.net/Articles/495543/|date=2012-05-02|work=[[LWN.net]]}}</ref> When a page is removed from the inactive set, it is paged out of physical memory. The size of the "active" and "inactive" list can be queried from <code>/proc/meminfo</code> in the fields "Active", "Inactive", "Active(anon)", "Inactive(anon)", "Active(file)" and "Inactive(file)".
 
== Working set ==
* [http://citeseer.ist.psu.edu/lee97implementation.html Implementation and Performance Evaluation of the LRFU Replacement Policy]
{{main|Working set}}
The working set of a process is the set of pages expected to be used by that process during some time interval.
 
The "working set model" isn't a page replacement algorithm in the strict sense (it's actually a kind of [[scheduling (computing)#Medium-term scheduling|medium-term scheduler]]){{Clarify|date=August 2011}}
* [http://citeseer.ist.psu.edu/16869.html The LRU-K Page Replacement Algorithm For Database Disk Buffering]
 
== References ==
* [http://www.usenix.org/events/usenix01/full_papers/zhou/ MQ replacement algorithm]
{{reflist|30em}}
 
== Further reading ==
[[Category:Virtual memory]]
{{Div col|colwidth=30em}}
* {{cite journal|last=Wong|first=Kin-Yeung|title=Web cache replacement policies: a pragmatic approach|journal=IEEE Network|volume=20|issue=1|pages=28–34|date=23 January 2006|doi=10.1109/MNET.2006.1580916|issn=0890-8044|publisher=IEEE|s2cid=17969287|language=en|id=INSPEC Accession Number 8964134}}
* {{cite journal|last2=Denning|first2=Peter J.|last3=Ullman|first3=Jeffrey D.|last1=Aho|first1=Alfred V.|title=Principles of Optimal Page Replacement|journal=Journal of the ACM|volume=18|issue=1|pages=80–93|date=January 1971|doi=10.1145/321623.321632|publisher=ACM|language=en|___location=New York, NY, USA|s2cid=3154537|doi-access=free}}
* {{cite book |first=Andrew S. |last=Tanenbaum |date=1997 |title=Operating Systems: Design and Implementation |edition=2nd |publisher=Prentice-Hall |___location=Upper Saddle River, NJ, USA |isbn=0-13-638677-6 |lccn=96037153 |ol=998396M |url=https://archive.org/details/operatingsystems00tane }}
* {{cite book |first=Andrew S. |last=Tanenbaum |date=2001 |title=Modern Operating Systems |edition=2nd |publisher=Prentice-Hall |___location=Upper Saddle River, NJ, USA |isbn=978-0-13-031358-4 |lccn=00051666 |ol=24214243M |oclc=45284637 |url=https://archive.org/details/modernoperatings00tane }} Online excerpt on page replacement algorithms: [http://www.informit.com/articles/article.aspx?p=25260 Page Replacement Algorithms].
* {{cite conference |first2=Pei |last2=Cao |url=https://dl.acm.org/citation.cfm?id=258681 |title=Adaptive page replacement based on memory reference behavior |first1=Gideon |last1=Glass |date=15-18 June 1997 |conference=1997 ACM SIGMETRICS international conference on Measurement and modeling of computer systems |conference-url=https://dl.acm.org/citation.cfm?id=258612 |publisher=ACM |url-access=subscription |___location=Seattle, WA, USA |pages=115–126 |language=en |doi=10.1145/258612.258681 |isbn=0-89791-909-2|doi-access=free }} Also available in extended form as {{cite journal|url=https://minds.wisconsin.edu/handle/1793/60102|title=Technical Report 1338|website=Department of Computer Sciences, University of Wisconsin-Madison|year=1997|last1=Glass|first1=Gideon|last2=Cao|first2=Pei}}
* {{cite conference |url=https://www.usenix.org/legacy/events/osdi2000/full_papers/kim/kim.pdf |title=A Low-Overhead High-Performance Unified Buffer Management Scheme that Exploits Sequential and Looping References |url-status=live |archive-url=https://web.archive.org/web/20040918122454/http://ssrnet.snu.ac.kr/~choijm/paper/IC-2000-OSDI-UBM.pdf |archive-date=18 September 2004|language=en |last2=Choi |first2=Jongmoo |last3=Kim |first3=Jesung |last1=Kim |first1=Jong Min |last4=Noh |first4=Sam H. |last5=Min |first5=Sang Lyul |last6=Cho |first6=Yookun |last7=Kim |first7=Chong Sang |date=17–21 October 2000 |conference=4th Usenix Symposium on Operating System Design and Implementation (OSDI'2000) |conference-url=http://www.usenix.org/events/osdi2000/ |___location=San Diego, CA, USA |display-authors=1 |publisher=USENIX Association |volume=4 |issue=9}}
* {{cite conference |first3=Paul |last3=Wilson |first2=Scott |last2=Kaplan |url=http://www.amherst.edu/~sfkaplan/courses/spring-2004/cs40/papers/SKW:EELRUSEAPR.pdf |title=EELRU: simple and effective adaptive page replacement |first1=Yannis |last1=Smaragdakis |date=1-4 May 1999 |conference=1999 ACM SIGMETRICS international conference on Measurement and modeling of computer systems |conference-url=https://dl.acm.org/citation.cfm?id=301453&picked=prox |publisher=ACM |archive-url=http://archive.wikiwix.com/cache/20160304000000/http://www.amherst.edu/~sfkaplan/courses/spring-2004/cs40/papers/SKW:EELRUSEAPR.pdf |archive-date=4 March 2016 |___location=Atlanta, GA, USA |pages=122–133 |url-status=live |language=en |isbn=1-58113-083-X |doi=10.1145/301453.301486}}
* {{cite conference |first2=Xiaodong |last2=Zhang |url=http://www.cse.ohio-state.edu/hpcs/WWW/HTML/publications/papers/TR-02-6.pdf |title=LIRS: a Low Inter Reference recency Set replacement |first1=Song |last1=Jiang |date=15-19 June 2002 |conference=2002 ACM SIGMETRICS international conference on Measurement and modeling of computer systems |conference-url=https://dl.acm.org/citation.cfm?id=511334&picked=prox |publisher=ACM |archive-url=http://archive.wikiwix.com/cache/20190612074945/http://www.cse.ohio-state.edu/hpcs/WWW/HTML/publications/papers/TR-02-6.pdf |archive-date=12 June 2019 |___location=Marina Del Rey, CA, USA |pages=31–42 |url-status=live |language=en |isbn=1-58113-531-9 |doi=10.1145/511334.511340}}
* {{cite conference |first2=Jongmoo |last2=Choi |title=Implementation and Performance Evaluation of the LRFU Replacement Policy |first1=Donghee |last1=Lee |date=1-4 September 1997 |conference=23rd Euromicro Conference New Frontiers of Information Technology |conference-url=http://csdl2.computer.org/persagen/DLAbsToc.jsp?resourcePath=/dl/proceedings/euromicro/&toc=comp/proceedings/euromicro/1997/8215/00/8215toc.xml |publisher=IEEE Computer Society |___location=Budapest, Hungary |pages=106–111 |language=en |isbn=0-8186-8215-9 |doi=10.1109/EMSCNT.1997.658446 |display-authors=1 |last3=Choe |first3=Honggi |last4=Noh |first4=Sam H. |last5=Min |first5=Sang Lyul |last6=Cho |first6=Yookun |id=INSPEC Accession Number 5856800}}
* {{cite conference |first2=James |last2=Philbin |url=http://usenix.org/publications/library/proceedings/usenix01/full_papers/zhou/zhou.pdf |title=The Multi-Queue Replacement Algorithm for Second-Level Buffer Caches |first1=Yuanyuan |last1=Zhou |date=25-30 June 2001 |conference=2001 USENIX Annual Technical Conference |conference-url=https://www.usenix.org/conference/2001usenixannualtechnicalconference |publisher=USENIX Association |___location=Boston, MA, USA |pages=91–104 |url-status=live |language=en |isbn=1-880446-09-X |last3=Li |first3=Kai |archive-url=https://web.archive.org/web/20051124142243/http://www.usenix.org/events/usenix01/full_papers/zhou/zhou.pdf| archive-date=24 November 2005}}
{{div col end}}
 
{{DEFAULTSORT:Page Replacement Algorithm}}
[[ja:ページ置換アルゴリズム]]
[[Category:Virtual memory]]
[[Category:Memory management algorithms]]
[[Category:Online algorithms]]
[[Category:Articles with example Python (programming language) code]]