中科大操作系统原理与实现课件9_VirtualMemory2.pdf
《中科大操作系统原理与实现课件9_VirtualMemory2.pdf》由会员分享,可在线阅读,更多相关《中科大操作系统原理与实现课件9_VirtualMemory2.pdf(40页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、.操作系统原理与设计第9章 VM(虚存2)陈香兰中国科学技术大学计算机学院2009年09月01日.提纲Page ReplacementBasic Page ReplacementFirst-In-First-Out(FIFO)AlgorithmOptimal AlgorithmLeast Recently Used(LRU)AlgorithmLRU Approximation AlgorithmsCounting AlgorithmsPage-Buffeing AlgorithmsAllocation of Frames小结和作业.Page Replacement IIFree page fr
2、ame is managed by OS using free-frame-listIWhat happens if there is no free frame?IPage replacementIover-allocationIno free frames;Iall memory is in useIPrevent over-allocation of memory by modifying page-faultservice routine to include page replacementIexample:.Page Replacement II.OutlinePage Repla
3、cementBasic Page ReplacementFirst-In-First-Out(FIFO)AlgorithmOptimal AlgorithmLeast Recently Used(LRU)AlgorithmLRU Approximation AlgorithmsCounting AlgorithmsPage-Buffeing AlgorithmsAllocation of Frames小结和作业.Basic Page Replacement1.Find the location of the desired page on disk2.Find a free frame:IIf
4、 there is a free frame,use itIIf there is no free frame,use a page replacement algorithm toselect a victim frame3.Bring the desired page into the(newly)free frame;update thepage and frame tables4.Restart the process.Page Replacement.INO MODIFY,NO WRITTEN(to disk/swap space)IUse modify(dirty)bit to r
5、educe overhead of page transfersIonly modified pages are written to diskIThis technique also applies to read-only pagesIfor example,pages of binary codeIPage replacement completes separation between logicalmemory and physical memoryIlarge virtual memory can be provided on a smaller physicalmemoryIde
6、mand paging,to lowest page-fault rate,two major problemsIframe-allocation algorithmsIpage-replacement algorithms.Page Replacement Algorithms IIGOAL:to lowest page-fault rateIDifferent algorithms are evaluated by running it on aparticular string of memory references(reference string)andcomputing the
7、number of page faults on that stringIA reference string isa sequence of addresses referenced by a programIExample:IAn address reference string:0100 0432 0101 0612 0102 0103 0104 0101 0611 0103 01040101 0610 0102 0103 0104 0101 0609 0102 0105IAssuming page size=100 B,then its corresponding pagerefere
8、nce string is:1 4 1 6 1 6 1 6 1 6 1.Page Replacement Algorithms IIIhow many page faults?Idetermined by the number of page frames assigned to theprocessIif 3,then only 3 page faultsIif=1,11 pages faults.Graph of Page Faults Versus The Number of Frames.IIn all our examples,the reference string is1,2,3
9、,4,1,2,5,1,2,3,4,5Ianother one is7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1.OutlinePage ReplacementBasic Page ReplacementFirst-In-First-Out(FIFO)AlgorithmOptimal AlgorithmLeast Recently Used(LRU)AlgorithmLRU Approximation AlgorithmsCounting AlgorithmsPage-Buffeing AlgorithmsAllocation of Frames小结和作业.Fi
10、rst-In-First-Out(FIFO)Algorithm I1.example 12.Reference string:1,2,3,4,1,2,5,1,2,3,4,5Iif 3 frames.First-In-First-Out(FIFO)Algorithm IIIif 4 framesIBeladys(贝莱迪)Anomaly:more frames more page faults.FIFO Illustrating Beladys AnomalyImore memory,better performance?MAY BE NOT!IBeladys anomaly.OutlinePag
11、e ReplacementBasic Page ReplacementFirst-In-First-Out(FIFO)AlgorithmOptimal AlgorithmLeast Recently Used(LRU)AlgorithmLRU Approximation AlgorithmsCounting AlgorithmsPage-Buffeing AlgorithmsAllocation of Frames小结和作业.Optimal AlgorithmIReplace page that will not be used for longest period of timeI4 fra
12、mes example1,2,3,4,1,2,5,1,2,3,4,5IHow do you know this?IUsed for measuring how well your algorithm performs.Optimal Page Replacement.OutlinePage ReplacementBasic Page ReplacementFirst-In-First-Out(FIFO)AlgorithmOptimal AlgorithmLeast Recently Used(LRU)AlgorithmLRU Approximation AlgorithmsCounting A
13、lgorithmsPage-Buffeing AlgorithmsAllocation of Frames小结和作业.Least Recently Used(LRU)Algorithm IIReference string:1,2,3,4,1,2,5,1,2,3,4,5.Least Recently Used(LRU)Algorithm IIHOW to implement LRU replacement?1.Counter implementationIEvery page entry has a counter;every time page is referencedthrough th
14、is entry,copy the clock into the counterIWhen a page needs to be changed,look at the counters todetermine which are to change2.Stack implementation keep a stack of page numbers in adouble link form:IPage referenced:Imove it to the topIrequires 6 pointers to be changedINo search for replacementIstack
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 中科大 操作系统 原理 实现 课件 _VirtualMemory2
限制150内