版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
CHAPTER 9 Virtual MemoryPracticeExercisesUnderwhatcircumstancesdopagefaultsoccur?Describetheactionstakenbytheoperatingsystemwhenapagefaultoccurs.Answer:Apagefaultoccurswhenanaccesstoapagethathasnotbeenbroughtintomainmemorytakesplace.Theoperatingsystemveriesthememoryaccess,abortingtheprogramifitisinvalid.Ifitisvalid,afreeframeislocatedandI/Oisrequestedtoreadtheneededpageintothefreeframe.UponcompletionofI/O,theprocesstableandpagetableareupdatedandtheinstructionisrestarted.Assumethatyouhaveareferencestringforaprocesswithmframes(initiallyallempty).Thereferencestringhaslengthp;ndistinctpagenumbersoccurinit.Answerthesequestionsforreplacementalgorithms:Whatisalowerboundonthenumberofpagefaults?Whatisanupperboundonthenumberofpagefaults?Answer:npConsiderthepagetableshowninFigure9.30forasystemwith12-bitvirtualandphysicaladdressesandwith256-bytepages.ThelistoffreepageframesisD,E,F(thatis,Disattheheadofthelist,Eissecond,andFislast).Convertthefollowingvirtualaddressestotheirequivalentphysicaladdressesinhexadecimal.Allnumbersaregiveninhexadecimal.dashforapageframeindicatesthatthepageisnotinmemory.)9EF1112930Chapter9VirtualMemory7000FFAnswer:9EF-0EF111-211700-D000FF-EFFConsiderthefollowingreplacementalgorithms.Rankalgorithmsonafive-pointscalefrom“bad”to“perfect”accordingtotheirfaultrate.SeparatethosealgorithmsthatsufferfromBelady’sanomalyfromthosethatdonot.LRUreplacementFIFOreplacementOptimalreplacementSecond-chancereplacementAnswer:RankAlgorithmSufferfromBelady’sanomalyOptimalnoLRUnoSecond-chanceyesFIFOyesDiscussthehardwaresupportrequiredtosupportdemandpaging.Answer:Foreverymemory-accessoperation,thepagetableneedstobeconsultedtocheckwhetherthecorrespondingpageisresidentornotandwhethertheprogramhasreadorwriteprivilegesforaccessingthepage.Thesecheckshavetobeperformedinhardware.ATLBcouldserveasacacheandimprovetheperformanceofthelookupoperation.Anoperatingsystemsupportsapagedvirtualmemory,usingacentralprocessorwithacycletimeof1microsecond.Itcostsanadditional1microsecondtoaccessapageotherthanthecurrentone.Pageshave1000words,andthepagingdeviceisadrumthatrotatesat3000revolutionsperminuteandtransfers1millionwordspersecond.Thefollowingstatisticalmeasurementswereobtainedfromthesystem:1percentofallinstructionsexecutedaccessedapageotherthanthecurrentpage.•Oftheinstructionsthataccessedanotherpage,80percentaccessedapagealreadyinmemory.PracticeExercises31•Whenanewpagewasrequired,thereplacedpagewasmodified50percentofthetime.Calculatetheeffectiveinstructiontimeonthissystem,assumingthatsystemisrunningoneprocessonlyandthattheprocessorisidleduringdrumtransfers.Answer:effectiveaccesstime=0.99×(1 sec+0.008×(2 sec)+0.002×(10,000 sec+1,000 sec)+0.001×(10,000 sec+1,000 sec)=(0.99+0.016+22.0+11.0)sec=34.0 secConsiderthetwo-dimensionalarrayA:intA[][]=newint[100][100];whereA[0][0]isatlocation200inapagedmemorysystemwithpagesofsize200.Asmallprocessthatmanipulatesthematrixresidesinpage0(locations0to199).Thus,everyinstructionfetchwillbefrompage0.Forthreepageframes,howmanypagefaultsaregeneratedbythefollowingarray-initializationloops,usingLRUreplacementandassumingthatpageframe1containstheprocessandtheotherareinitiallyempty?a.for(intj=0;j<100;for(inti=0;i<100;i++)A[i][j]=0;b.for(inti=0;i<100;for(intj=0;j<100;j++)A[i][j]=0;Answer:a.5,000b.50Considerthefollowingpagereferencestring:1,2,3,4,2,1,5,6,2,1,2,3,7,6,3,2,1,2,3,6.Howmanypagefaultswouldoccurforthefollowingreplacementalgorithms,assumingone,two,three,four,five,six,orsevenframes?Rememberallframesareinitiallyempty,soyourfirstuniquepageswillallcostonefaulteach.•LRUreplacementFIFOreplacement•Optimalreplacement32Chapter9VirtualMemoryAnswer:NumberofframesLRUFIFOOptimal12020202181815315161141014858107671077777Supposethatyouwanttouseapagingalgorithmthatrequiresreferencebit(suchassecond-chancereplacementorworking-setmodel),butthehardwaredoesnotprovideone.Sketchhowyoucouldsimulatereferencebitevenifonewerenotprovidedbythehardware,orexplainwhyitisnotpossibletodoso.Ifitispossible,calculatewhatthecostwouldbe.Answer:Youcanusethevalid/invalidbitsupportedinhardwaretosimulatethereferencebit.Initiallysetthebittoinvalid.rstreferenceatraptotheoperatingsystemisgenerated.Theoperatingsystemwillsetasoftwarebitto1andresetthevalid/invalidbittovalid.Youhavedevisedanewreplacementalgorithmthatyouthinkmaybeoptimal.Insomecontortedtestcases,Belady’sanomalyoccurs.Isthenewalgorithmoptimal?ExplainyourAnswer:No.AnoptimalalgorithmwillnotsufferfromBelady’sanomalybecause—bydefinition—anoptimalalgorithmreplacesthepagethatwillnotbeusedforthelongesttime.Belady’sanomalyoccurswhenapagereplacementalgorithmevictsapagethatwillbeneededintheimmediatefuture.Anoptimalalgorithmwouldnothaveselectedsuchapage.Segmentationissimilartopagingbutvariable-sized“pages.”Definetwosegment-replacementalgorithmsbasedonFIFOandLRUpagereplacementschemes.Rememberthatsincesegmentsarenotthesamesize,thesegmentthatischosentobereplacedmaynotbebigenoughtoleaveenoughconsecutivelocationsfortheneededsegment.Considerstrategiesforsystemswheresegmentscannotberelocated,andthoseforsystemswheretheycan.Answer:FIFO.Findthefirstsegmentlargeenoughtoaccommodatetheincomingsegment.Ifrelocationisnotpossibleandnoonesegmentislargeenough,selectacombinationofsegmentswhosememoriesarecontiguous,whichare“closesttothefirstofthelist”andwhichcanaccommodatethenewsegment.Ifrelocationispossible,rearrangethememorysothatthefirstNsegmentslargeenoughfortheincomingsegmentarecontiguousinmemory.Addanyleftoverspacetothefree-spacelistinbothcases.PracticeExercises33LRU.Selectthesegmentthathasnotbeenusedforthelongestperiodoftimeandthatislargeenough,addinganyleftoverspacetothefreespacelist.Ifnoonesegmentislargeenough,selectacombinationofthe“oldest”segmentsthatarecontiguousinmemory(ifrelocationisnotavailable)andthatarelargeenough.Ifrelocationisavailable,rearrangetheoldestNsegmentstobecontiguousinmemoryandreplacethosewiththenewsegment.Considerademanddcomputersystemwherethedegreeofmultiprogrammingiscurrentlyfixedatfour.ThesystemwasrecentlymeasuredtodetermineutilizationofCPUandthepagingdisk.Theresultsareoneofthefollowingalternatives.Foreachcase,whatishappening?CanthedegreeofmultiprogrammingbeincreasedtoincreasetheCPUutilization?Isthepaginghelping?CPUutilization13percent;diskutilization97percentCPUutilization87percent;diskutilization3percentCPUutilization13percent;diskutilization3percentAnswer:Thrashingisoccurring.CPUutilizationissufficientlyhightoleavethingsalone,andincreasedegreeofmultiprogramming.Increasethedegreeofmultiprogramming.Wehaveanoperatingsystemforamachinethatusesbaseandlimitregisters,butwehavemodifiedthemachinetoprovideapagetable.Canthepagetablesbesetuptosimulatebaseandlimitregisters?Howcantheybe,orwhycantheynotbe?Answer:Thepagetablecanbesetuptosimulatebaseandlimitregistersprovidedthatthememoryisallocatedinfixed-sizesegments.Inthisway,thebaseofasegmentcanbeenteredintothepagetableandthevalid/invalidbitusedtoindicatethatportionofthesegmentasresidentinthememory.Therewillbesomeproblemwithinternalfragmentation.9.27.Considerademand-pagingsystemwiththefollowingtime-measuredutilizations:CPUutilization20%Pagingdisk97.7%OtherI/OdevicesWhich(ifany)ofthefollowingwill(probably)improveCPUutilization?Explainyouranswer.InstallafasterCPU.Installabiggerpagingdisk.Increasethedegreeofmultiprogramming.Decreasethedegreeofmultiprogramming.Installmoremainmemory.Installafasterharddiskormultiplecontrollerswithmultipledisks.Addprepagingtothepagefetchalgorithms.Increasethepagesize.Answer:Thesystemobviouslyisspendingmostofitstimepaging,indicatingover-allocationofmemory.IfthelevelofmultiprogrammingisreducedresidentprocesseswouldpagefaultlessfrequentlyandtheCPUutilizationwouldimprove.Anotherwaytoimproveperformancewouldbetogetmorephysicalmemoryorafasterpagingdrum.GetafasterCPU—No.Getabiggerpagingdrum—No.Increasethedegreeofmultiprogramming—No.Decreasethedegreeofmultiprogramming—Yes.Installmoremainmemory—LikelytoimproveCPUutilizationmorepagescanremainresidentandnotrequirepagingtoorfromthedisks.Installafasterharddisk,ormultiplecontrollerswithmultipledisks—Alsoanimprovement,forasthediskbottleneckisremovedbyfasterresponseandmorethroughputtothedisks,theCPUwillgetmoredatamorequickly.Addprepagingtothepagefetchalgorithms—Again,theCPUwillgetmoredatafaster,soitwillbemoreinuse.Thisisonlythecaseifthepagingactionisamenabletoprefetching(i.e.,someoftheaccessissequential).Increasethepagesize—Increasingthepagesizewillresultinpagefaultsifdataisbeingaccessedsequentially.Ifdataaccessismoreorlessrandom,morepagingactioncouldensuebecausefewerpagescanbekeptinmemoryandmoredataistransferredperpagefault.Sothischangeisaslikelytodecreaseutilizationasitistoincreaseit.10.110.1、Isdiskscheduling,otherthanFCFSscheduling,usefulinasingle-usersingle-userenvironment?Explainyourenvironment?Explainyouranswer.Answer:Answer:Inasingle-userenvironment,theI/Oqueueusuallyisempty.RequestsRequestsgenerallyarrivefromasingleprocessforoneblockorforaperformingconcurrentI/O,suchaswhenaWebbrowserretrievesdatainthebackgroundwhiletheoperatingsystemispagingandanothersequenceofconsecutiveblocks.Inthesecases,FCFSisaneconomicalmethodofdiskscheduling.ButperformingconcurrentI/O,suchaswhenaWebbrowserretrievesdatainthebackgroundwhiletheoperatingsystemispagingandanotherapplicationisactiveintheforeground.10.2.Explain10.2.ExplainwhySSTFschedulingtendstofavormiddlecylindersovertheovertheinnermostandoutermostinnermostandoutermostcylinders.The center of the disk is the location having the The center of the disk is the location having the smallesttheheadisnotinthecenterofthediskandanewrequestarrives,thenewrequestismorelikelytobeinthegroupthatincludesthecenteraveragedistancetotheheadisnotinthecenterofthediskandanewrequestarrives,thenewrequestismorelikelytobeinthegroupthatincludesthecenterofthedisk;thus,theheadismorelikelytomoveinthatdirection.10.11Supposethatadiskdrivehas5000cylinders,numbered0to4999.Thedriveiscurrentlyservingarequestatcylinder143,andthepreviousrequestwasatcylinder125.Thequeueofpendingrequests,inFIFOorder,is86,1470,913,1774,948,1509,1022,1750,130Startingfromthecurrentheadposition,whatisthetotaldistance(incylinders)thatthediskarmmovestosatisfyallthependingrequests,foreachofthefollowingdisk-schedulingalgorithms?FCFSSSTFSCANLOOKC-SCANAnswer:a.TheFCFSscheduleis143,86,1470,913,1774,948,1509,1022,1750,130.Thetotalseekdistanceis7081.b.TheSSTFscheduleis143,130,86,913,948,1022,1470,1509,1750,1774.Thetotalseekdistanceis1745.c.TheSCANscheduleis143,913,948,1022,1470,1509,1750,1774,4999,130,86.Thetotalseekdistanceis9769.d.TheLOOKscheduleis143,913,948,1022,1470,1509,1750,1774,130,86.Thetotalseekdistanceis3319.e.TheC-SCANscheduleis143,913,948,1022,1470,1509,1750,1774,4999,86,130.Thetotalseekdistanceis9813.f.(Bonus.)TheC-LOOKscheduleis143,913,948,1022,1470,1509,1750,1774,86,130.Thetotalseekdistanceis3363.12CHAPTER12CHAPTERImplementationPracticeExercises12.1Considerafilecurrentlyconsistingof100blocks.Assumethatthe12.1Considerafilecurrentlyconsistingof100blocks.Assumethatthefilecontrolblock(andtheindexblock,inthecaseofindexedallocation)filecontrolblock(andtheindexblock,inthecaseofindexedallocation)isalreadyinmemory.CalculatehowmanydiskI/Ooperationsarerequiredforcontiguous,linked,andindexed(single-level)allocationstrategies,if,foroneblock,thefollowingconditionshold.Inthecontiguous-allocationcontiguous-allocationcase,assumethatthereisnoroomtogrowthethebeginningbutthereisroomtogrowattheend.Alsoassumetheblockinformationtobeaddedisstoredinmemory.Theblockisaddedatthebeginning.Theblockisaddedinthemiddle.c.c.Theblockisaddedattheend.d.Theblockisremovedfromthebeginning.e.Theblockisremovedfromthemiddle.f.Theblockisremovedfromtheend.Answer:Theresultsare:ContiguousLinkedIndexedContiguousLinkedIndexeda.20111b.101521c.131d.19810e.98520f.f.0100012.2Whatproblemscouldoccurifasystemallowedafilesystemtobemountedsimultaneouslyatmorethanonelocation?Answer:4344Chapter12 ImplementationTherewouldbemultiplepathstothesamefile,whichcouldconfuseusersorencouragemistakes(deletingafilewithonepathdeletestheTherewouldbemultiplepathstothesamefile,whichcouldconfuseusersorencouragemistakes(deletingafilewithonepathdeletesthefileinalltheotherpaths).Whymustthebitmapfor fileallocationbekeptonmassstorage, ratherthanthaninmainmemory?Answer:Incaseofsystemcrash(memoryfailure)thefree-spacelistwouldbelostasitwouldbeifthebitmaphadbeenstoredinmainmemory.Considerasystemthatsupportsthestrategiesofcontiguous,linked,andindexedallocation.Whatcriteriashouldbeusedindecidingwhichstrategyisbestutilizedforaparticularfile?strategyisbestutilizedforaparticularfile?Answer:Answer:•Contiguous—iffileisusuallyaccessedsequentially,iffileisrelativelysmall.•Linked—Linked—iffileislargeandusuallyaccessedsequentially.Indexed—iffileislargeandusuallyaccessedrandomly.Oneproblemwithcontiguousallocationisthattheusermustpreallocateenoughspaceforeachfile.Ifthefilegrowstobelargerthanthespacespaceallocatedforit,specialactionsmustbetaken.Onesolutiontothisproblemistodefineafilestructureconsistingofaninitialcontiguousproblemistodefineafilestructureconsistingofaninitialcontiguousarea(ofaspecifiedsize).Ifthisareaisfilled,theoperatingsystemautomaticallydefinesanoverflowareathatislinkedtotheinitialcontiguousarea.Iftheoverflowareaisfilled,anotheroverflowareaisallocated.Comparethisimplementationofafilewiththestandardisallocated.Comparethisimplementationofafilewiththestandardcontiguousandlinkedcontiguousandlinkedimplementations.Answer:Thismethodrequiresmoreoverheadthenthestandardcontiguousallocation.Itrequireslessoverheadthanthestandardlinkedallocation.Howdocacheshelpimproveperformance?Whydosystemsnotusemoreormoreorlargercachesiftheyaresouseful?Answer:Cachesallowcompon
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年哈尔滨医科大学附属第二医院公开招聘病房主任、副主任岗位15人备考笔试题库及答案解析
- 深度解析(2026)《GBT 26882.1-2024粮油储藏 粮情测控系统 第1部分:通则》
- 深度解析(2026)《GBT 26025-2010连续铸钢结晶器用铜模板》(2026年)深度解析
- 深度解析(2026)《GBT 25669.1-2010镗铣类数控机床用工具系统 第1部分:型号表示规则》(2026年)深度解析
- 2025山东聊城市属国有控股公司电商平台项目招聘100人备考笔试题库及答案解析
- 2025广东中山市民众锦标学校教师招聘参考考试试题及答案解析
- 2025河南开封职业学院招聘专职教师81人参考考试试题及答案解析
- 2025年甘肃省嘉峪关市人民社区卫生服务中心招聘备考考试题库及答案解析
- 2025云南昆华医院投资管理有限公司(云南新昆华医院)招聘(3人)模拟笔试试题及答案解析
- 2025年东北农业大学财务处招聘3人参考考试题库及答案解析
- 酒店情况诊断报告
- GB/T 45795-2025大气颗粒物PM10、PM2.5质量浓度观测光散射法
- 2025年夏季山东高中学业水平合格考地理试卷试题(含答案)
- DBJ04-T483-2025 海绵型城市道路与广场设计标准
- 农药运输储存管理制度
- TD/T 1036-2013土地复垦质量控制标准
- 童年的阅读测试题及答案
- 爆破备案工作报告
- 客户押款协议书范本
- 地理建筑特征教案课件
- 1.1幂的乘除第4课时(课件)-2024-2025学年七年级数学下册同步课堂(北师大版)
评论
0/150
提交评论