pLRU替换策略的建议实现.pdf

pLRU替换策略的建议实现.pdf

ID:48069360

大小:50.91 KB

页数:2页

时间:2019-10-25

pLRU替换策略的建议实现.pdf_第1页
pLRU替换策略的建议实现.pdf_第2页
资源描述:

《pLRU替换策略的建议实现.pdf》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、LRUreplacementpolicyLeastRecentlyUsed(LRU)replacementpolicyisusedreplacethecachelineorpagethatisleastrecentlyused.ForBlock/LinereplacementinAssociativeCachesSincecachemanagementispurelydoneinhardware,implementingthisalgorithmcanbeexpensiveintermsofbitne

2、ededformaintaininghistoryofreferences.ThepseudoLRUversionisimplementedusingbinarysearchapproach.Examplefour-waysetassociativerequiresthreebitstokeeptrackofmostrecentlyusedline.Inorderunderstandthediagrambelowrefertofollowingdefinition:•eachbitrepresents

3、onebranchpointinabinarydecisiontree•let1representthattheleftsidehasbeenreferencedmorerecentlythantherightside,and0vice-versaareall4linesvalid?/yesno,useaninvalidline

4、

5、

6、bit_0==0?state

7、replacerefto

8、nextstate/------+---------------+-----------yn00x

9、line_

10、0line_0

11、11_/1x

12、line_1line_1

13、10_bit_1==0?bit_2==0?1x0

14、line_2line_2

15、0_1//1x1

16、line_3line_3

17、0_0ynyn//('x'means('_'meansunchanged)line_0line_1line_2line_3don'tcare)ForPageReplacementinVirtualMemoryAperfectimplementationofLRUrequiresatimestamponeachrefe

18、rence,andtheOSneedstokeepalistofpagesorderedbythetimestamp.However,thisimplementationistooexpensiveconsideringthefrequencyofmemoryreferences.ThecommonpracticeistoapproximatetheLRUbehavior.Onesuchapproximationisdoneusingclockalgorithm.ClockAlgorithmTheid

19、eaofapproximatingtheLRUreplacementpolicyistoreplaceanoldpage,nottheoldestpage.Theclockalgorithmarrangesphysicalpagesinacircle,withaclockhand.Ausebitisusedforeachphysicalpage.Theusebitissetto1oneachreference.Iftheusebitisnotset,itmeansthatthepagehasnotbe

20、enreferencedforsometime.00101010Onpagefault,theclockhandstartstosweepclock-wise.Ifitencountersausebitthatissetto1,itsetsitto0andmoveson.Iftheusebitis0,thepageischosenforreplacement.Intheworstcaseallusebitsmightbesetandthepointercyclesthroughalltheframes

21、,givingeachpageasecondchance.Aslowmovinghandmeansthatpagesareeitherfoundquickly,ortherearefewpagefaults.Aquickmovinghandmeanslotsofpagefaults,orlotsofuse-bitsets.Onesimplewaytoviewtheclockingalgorithmisthatofacrudepartitioningofp

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。