操作系統(tǒng)第九版部分課后作業(yè)習(xí)題答案分析解析_第1頁(yè)
操作系統(tǒng)第九版部分課后作業(yè)習(xí)題答案分析解析_第2頁(yè)
操作系統(tǒng)第九版部分課后作業(yè)習(xí)題答案分析解析_第3頁(yè)
操作系統(tǒng)第九版部分課后作業(yè)習(xí)題答案分析解析_第4頁(yè)
操作系統(tǒng)第九版部分課后作業(yè)習(xí)題答案分析解析_第5頁(yè)
已閱讀5頁(yè),還剩13頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

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.Rankalgorithmsona?ve-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,thereplacedpagewasmodi?ed50percentofthetime.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,?ve,six,orsevenframes?Rememberallframesareinitiallyempty,soyour?rstuniquepageswillallcostonefaulteach.?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—byde?nition—anoptimalalgorithmreplacesthepagethatwillnotbeusedforthelongesttime.Belady’sanomalyoccurswhenapagereplacementalgorithmevictsapagethatwillbeneededintheimmediatefuture.Anoptimalalgorithmwouldnothaveselectedsuchapage.Segmentationissimilartopagingbutvariable-sized“pages.”De?netwosegment-replacementalgorithmsbasedonFIFOandLRUpagereplacementschemes.Rememberthatsincesegmentsarenotthesamesize,thesegmentthatischosentobereplacedmaynotbebigenoughtoleaveenoughconsecutivelocationsfortheneededsegment.Considerstrategiesforsystemswheresegmentscannotberelocated,andthoseforsystemswheretheycan.Answer:FIFO.Findthe?rstsegmentlargeenoughtoaccommodatetheincomingsegment.Ifrelocationisnotpossibleandnoonesegmentislargeenough,selectacombinationofsegmentswhosememoriesarecontiguous,whichare“closesttothe?rstofthelist”andwhichcanaccommodatethenewsegment.Ifrelocationispossible,rearrangethememorysothatthe?rstNsegmentslargeenoughfortheincomingsegmentarecontiguousinmemory.Addanyleftoverspacetothefree-spacelistinbothcases.PracticeExercises33LRU.Selectthesegmentthathasnotbeenusedforthelongestperiodoftimeandthatislargeenough,addinganyleftoverspacetothefreespacelist.Ifnoonesegmentislargeenough,selectacombinationofthe“oldest”segmentsthatarecontiguousinmemory(ifrelocationisnotavailable)andthatarelargeenough.Ifrelocationisavailable,rearrangetheoldestNsegmentstobecontiguousinmemoryandreplacethosewiththenewsegment.Considerademanddcomputersystemwherethedegreeofmultiprogrammingiscurrently?xedatfour.ThesystemwasrecentlymeasuredtodetermineutilizationofCPUandthepagingdisk.Theresultsareoneofthefollowingalternatives.Foreachcase,whatishappening?CanthedegreeofmultiprogrammingbeincreasedtoincreasetheCPUutilization?Isthepaginghelping?CPUutilization13percent;diskutilization97percentCPUutilization87percent;diskutilization3percentCPUutilization13percent;diskutilization3percentAnswer:Thrashingisoccurring.CPUutilizationissuf?cientlyhightoleavethingsalone,andincreasedegreeofmultiprogramming.Increasethedegreeofmultiprogramming.Wehaveanoperatingsystemforamachinethatusesbaseandlimitregisters,butwehavemodi?edthemachinetoprovideapagetable.Canthepagetablesbesetuptosimulatebaseandlimitregisters?Howcantheybe,orwhycantheynotbe?Answer:Thepagetablecanbesetuptosimulatebaseandlimitregistersprovidedthatthememoryisallocatedin?xed-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.1Considera?lecurrentlyconsistingof100blocks.Assumethatthe12.1Considera?lecurrentlyconsistingof100blocks.Assumethatthe?lecontrolblock(andtheindexblock,inthecaseofindexedallocation)?lecontrolblock(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.2Whatproblemscouldoccurifasystemalloweda?lesystemtobemountedsimultaneouslyatmorethanonelocation?Answer:4344Chapter12 ImplementationTherewouldbemultiplepathstothesame?le,whichcouldconfuseusersorencouragemistakes(deletinga?lewithonepathdeletestheTherewouldbemultiplepathstothesame?le,whichcouldconfuseusersorencouragemistakes(deletinga?lewithonepathdeletesthe?leinalltheotherpaths).Whymustthebitmapfor ?leallocationbekeptonmassstorage, ratherthanthaninmainmemory?Answer:Incaseofsystemcrash(memoryfailure)thefree-spacelistwouldbelostasitwouldbeifthebitmaphadbeenstoredinmainmemory.Considerasystemthatsupportsthestrategiesofcontiguous,linked,andindexedallocation.Whatcriteriashouldbeusedindecidingwhichstrategyisbestutilizedforaparticular?le?strategyisbestutilizedforaparticular?le?Answer:Answer:?Contiguous—if?leisusuallyaccessedsequentially,if?leisrelativelysmall.?Linked—Linked—if?leislargeandusuallyaccessedsequentially.Indexed—if?leislargeandusuallyaccessedrandomly.Oneproblemwithcontiguousallocationisthattheusermustpreallocateenoughspaceforeach?le.Ifthe?legrowstobelargerthanthespacespaceallocatedforit,specialactionsmustbetaken.Onesolutiontothisproblemistode?nea?lestructureconsistingofaninitialcontiguousproblemistode?nea?lestructureconsistingofaninitialcontiguousarea(ofaspeci?edsize).Ifthisareais?lled,theoperatingsystemautomaticallyde?nesanover?owareathatislinkedtotheinitialcontiguousarea.Iftheover?owareais?lled,anotherover?owareaisallocated.Comparethisimplementationofa?lewiththestandardisallocated.Comparethisimplementationofa?lewiththestandardcontiguousandlinkedcontiguousandlinkedimplementations.Answer:Thismethodrequiresmoreoverheadthenthestandardcontiguousallocation.Itrequireslessoverheadthanthestandardlinkedallocation.Howdocacheshelpimproveperformance?Whydosystemsnotusemoreormoreorlargercachesiftheyaresouseful?Answer:Cachesallowcompon

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論