首先我们在操作系统学过对虚存技术,为实现虚存,在页面置换时需要一些页面置换算法,此文章专注FIFO造成的belady现象进行简单解析。
Belady现象:
采用FIFO算法时,有时会出现分配的物理页数增加,缺页率反而提高的异常现象。
Belady现象的原因:
FIFI算法的置换特征与进程访问内存的动态特征矛盾,与置换算法的目标不一致,因此,被他置换出去的页面不一定是进程不访问的(可能将进程会访问的页置换出去了)。
此文belady原文和译:
Initiated by the observation of an unexpected phe-nomenon,a program behavior study has been presented.The study results in showing the existence of programshaving the following property : running on a paging machineand using the FIFO replacement algorithm,there areinstances when the program runs faster if one reduces thestorage space allotted to it.
通过对一个突发事件的观察,提出了一项程序行为研究。研究结果表明,程序存在以下特性:在分页机上运行,并使用FIFO替换算法,当程序减少分配给它的存储空间时,运行速度更快。
The study describes methods of constructing programs(i.e. storagc-reference strings ) which, for two storage sizesand running under the FIFO replacement algorithm,dis-play a (reversed ) page-exception ratio of up to 2 to 1.Though the programs thus constructed may seem tooregular and artificial,the fact that a real-life programhas been observed behaving similarly,and that the anom-aly has also been observed with a multiprogrammed mixof that program, suggests the possibility of FIFO producingthe anomaly in subsequences of reference strings.
本研究描述了构造程序(即存储-引用字符串)的方法,对于两个存储规模和在FIFO替换算法下运行的程序,dis-发挥高达2:1的(反向)页异常率,尽管这样构建的程序看起来过于规则和人为,实际生活中的程序也被观察到类似的行为,并且使用多程序混合程序也观察到了anom-Aly,这表明了FIFO在引用字符串序列中产生异常的可能性。
It should be borne in mind that the strings R, producedby the production rules, can be enlarged in a great varietyof ways with references which do not cause paging ineither the large or small stores. Essentially dissimilarprograms, after deletion of such type I references, may besimilar generators of the anomaly.
应该记住的是,由生产规则产生的字符串R可以以各种不同的方式扩展,引用不会导致在大商店或小商店中分页。在删除这类I类引用之后,本质上的异化程序可能是异常的类似生成体。
The anomaly is an indication of inefficiency of the FIFOalgorithm,which cyclically assigns page-frames upon de-mand and ignores any other pattern in the reference string.It is felt that the anomaly can be eliminated or itsoccurrence made very infrequent by using other replace-ment rules which keep track of recent references to pagesalready in store (see AR-1 in [2]).Some random selectionsuperimposed on FIFO might avoid the anomaly.
这种异常是FIFO算法效率低下的一个标志,它周期性地在de-mand上分配页面帧,并忽略引用字符串中的任何其他模式。通过使用其他替换规则(见[2]中有关页的最近引用(见[2]中的AR-1),认为可以消除异常或使异常发生得非常少)。
使用FIFO算法时
访问顺序 1,2,3,4,1,2,5,1,2,3,4,5
Frame Size:3 Page Fault:9 ->(命中)
FIFO | 1 | 2 | 3 | 4 | 1 | 2 | 5 | 1 | 2 | 3 | 4 | 5 |
Tail | 1 | 2 | 3 | 4 | 1 | 2 | 5 | 5 | 5 | 3 | 4 | 4 |
1 | 2 | 3 | 4 | 1 | 2 | 2 | 2 | 5 | 3 | 3 | ||
Head | 1 | 2 | 3 | 4 | 1 | 1 | 1 | 2 | 5 | 5 | ||
PF | X | X | X | X | X | X | X | -> | -> | X | X | -> |
访问顺序 1,2,3,4,1,2,5,1,2,3,4,5
Frame Size:4 Page Fault:10 ->(命中)
FIFO | 1 | 2 | 3 | 4 | 1 | 2 | 5 | 1 | 2 | 3 | 4 | 5 |
Tail | 1 | 2 | 3 | 4 | 4 | 4 | 5 | 1 | 2 | 3 | 4 | 5 |
1 | 2 | 3 | 3 | 3 | 4 | 5 | 1 | 2 | 3 | 4 | ||
1 | 2 | 2 | 2 | 3 | 4 | 5 | 1 | 2 | 3 | |||
Head | 1 | 1 | 1 | 2 | 3 | 4 | 5 | 1 | 2 | |||
PF | X | X | X | X | -> | -> | X | X | X | X | X | X |