Study of Page Replacement Algorithm Based On Experiment: Wang Hong
Study of Page Replacement Algorithm Based On Experiment: Wang Hong
Study of Page Replacement Algorithm Based On Experiment: Wang Hong
Abstract . The page replacement algorithm is an very important step which realize virtual memory
control. A good page replacement algorithm can reduce the fault frequency when program
executing, reduce the number of I/O, and then increase the systems efficiency effectively. In this
paper, we studied the principle of various of page replacement algorithm, designed an program
which simulated the procession and result of page replacement algorithm, in this program, we
assume a few condition, record the experiment results. According to these data, we compared and
analyzed the page fault and page fault frequency of different algorithm, and compare their
performance.
1.
Introduction
A programs execution process different fault rates as the amount of memory allocation varies. For
stack algorithms, as the memory size is decreased using any particular algorithm, the fault rate will
increase. Therefore, we will discuss the various of the policy of page replacement in follow, study
the frequency of page fault, and then decided which algorithm we will use in different system..
2.
330
ICMEA 2012
repeatedly read from and write to a subset of the data when it executes the program. For example, a
program that is solving a system of equations will tend to repeatedly reference the part of the
address space that contains the coefficient matrix for the system of equations. While almost all
programs have relatively small code localities, several classes of programs have no particularly
useful data locality. (For example, a transaction processing system usually has "poor data locality,"
meaning that there is no relationship between sequential data transactions.)
The LRU replacement algorithm is explicitly designed to take advantage of locality by assuming
that if a page has been referenced recently, it is likely to be referenced again soon. The backward
distance of page r at time t, BKWDt(r), is the distance (in the reference stream) from r to the last
occurrence of the page in the preceding part of the reference stream. The backward distance is
always greater than 0 and is infinite if the page has not been referenced previously. LRU selects a
page, yt for replancement with the maximum backward distance:
yt = max xst-l(m)=BKWDt(x).
The assumption is that because of locality, the backward distance is a good estimator of the
forward distance of any page. If more than one page has maximal backward distance, LRU may
choose an arbitrary page with maximal backward distance for replacement.
2.3 Optimal algorithm(OPT)
The optimal policy selects for replacement that page for which the time to the next reference is the
longest. It can be shown that this policy results in the fewest number of page faults. At the other
extreme from random replacement is the replacement policy having "perfect knowledge" of the
page reference stream; thus it always chose an optimal page to be removed from the memory. Let
the forward distance of a page r at time t, FWDt(r), be the distance from the current point in the
reference stream to the next place in the stream where the same page is referenced again. The
forward distance is always greater than 0 and is infinite if the page is never referenced again. In the
optimal algorithm, the replaced page, yt, is one that has maximal forward distance:
yt = max xst-l(m)=FWDt(x)
Since more than one page is loaded at time t. there may be more than one page that never appears
again in the reference stream--that is, there may be more than one loaded page with maximal
forward distance. In this case, Belady's optimal algorithm chooses an arbitrary loaded page with
maximal forward distance. The optimal algorithm can be implemented only if the full page
reference stream is known in advance. Since it is rate for the system to have such knowledge, the
algorithm is not generally realizable. Instead, its theoretical behavior is used to compare the
performance of realizable algorithms with the optimal performance.
331
main
Variable nitialization
end
In a few special cases (such as a program to predict the weather), large programs are used enough
to merit careful analysis of their paging behavior Although it is usually not possible to exactly
predict the page reference stream, one can sometimes predict the next page with high probability
that the prediction will be correct. For example, the conditional branch instruction at the end of a
loop almost always branches back to the beginning of the loop rather than exiting it. Such
predictions are based on static analysis of the source code or on observations of dynamic behavior
of the program. This analysis can produce enough information to incorporate replacement "hints" in
the source code, although the process is labor-intensive and only worthwhile on programs that are
long running and frequently executed. The compiler and paging systems can then be designed to
use these hints to predict the future behavior of the page reference stream.
3.
FIFO
LRU
OPT
18
17
11
22
21
14
20
21
13
18
20
13
23
22
13
23
23
16
22
22
15
215
25
14
20
22
13
10
13
12
10
order
4.
Conclusion
According to the experiment recorder, we analyzed the count data, we can made the conclusion:
The FIFO policy is very simple to implement, but performs relatively poorly. The optimally policy
is impossible to implement, because it would require the operating system to have perfect
knowledge of future events. However, it does serve as a standard against which to judge real-world
algorithms. The LRU algorithm is the nearest to the OPT algorithm..
333
References
[1] Feng HongWei, Wang Peng. Operating system teaching and experimental design research.
Laboratory research and exploration, in 2007, the 26th volume (12 issues): 251-253.
[2] Wang Hong, Hou Gang and so on, operating system Discipline (Linux)) - - exercise
explanation, sample question analysis, experimental instruction (the second edition). Beijing:
Water conservancy and Hydroelectric Power Press, August, 2008. 214-284.
[3] Yang Yanhang, Sun Bingxin. A Security Policy for Operating System, Journal of North-East
Forestry.
[4] Wang Yahui, Zhong Keding, Yuying. An Idea of Security Enhancement based on Linux
Operating System, Computer Applications and Software.
[5] Zhang Heng, Zhang Yusen, Lu Weidong, Implementation and Assessment on the Capability
Mechanism of Linux Security Enhancement System, Journal of System Simulation.
[6] Pan Yu, Han Jun, A Network Security Policy and Protection Measures Based on Linux
System , Computer and Information Technology.
[7] William Stallings, Operating Systems internals and design principles. Beijing: Electronic
Industry Press ,2006.3
[8] Gary Nutt. Operating systems:A Modern perspective . Beijing: Posts & Telecom Press ,
[9] Wu Xiaoming, Guo Yudong, Computer Security, Technology Forum
334