




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
Chapter99.3Describethefollowingallocationalgorithms:a.Firstfitb.Bestfitc.WorstfitFirstfit:搜索可用內(nèi)存列表,分配第一塊足夠大Bestfit:搜索整個可用內(nèi)存塊,分配最小足夠大Worstfit:搜索整個可用內(nèi)存塊,分配最大足夠大第1頁9-cont.9.5Givenmemorypartitionsof100K,500K,200K,300K,and600K(inorder),howwouldeachoftheFirst-fit,Best-fit,andWorst-fitalgorithmsplaceprocessesof212K,417K,112K,and426K(inorder)?Whichalgorithmmakesthemostefficientuseofmemory?Firstfit212->500(288)417->600(183)112->288426->noneBestfit212->300417->500112->200426->600Worstfit212->600(388)417->500112->388426->none第2頁9-cont.9.10Considerapagingsystemwiththepagetablestoredinmemory.a.Ifamemoryreferencetakes200nanoseconds,howlongdoesapagedmemoryreferencetake?b.Ifweaddassociativeregisters,and75percentofalltablereferencesarefoundintheassociativeregisters,whatistheeffectivememoryreferencetime?(Assumethatfindingatableentryintheassociativeregisterstakeszerotime,iftheentryisthere.)a.400,200(pagetable)+200(accessword)b.250,75%*200+25%*(200+200)第3頁9-cont.9.16Considerthefollowingsegmenttable:Whatarethephysicaladdressesforthefollowinglogicaladdresses?a.0,430b.1,10c.2,500d.3,400e.4,112a.430<600,219+430=649b.10<14,2300+10=2310c.500>100,illegald.400<580,1327+400=1727e.112>96,illegal第4頁9-cont.9.18IntheIBM/370,memoryprotectionisprovidedthroughtheuseofkeys.Akeyisa4-bitquantity.Each2Kblockofmemoryhasakey(thestoragekey)associatedwithit.TheCPUalsohasakey(theprotectionkey)associatedwithit.Astoreoperationisallowedonlyifbothkeysareequal,orifeitheriszero.Whichofthefollowingmemory-managementschemescouldbeusedsuccessfullywiththishardware?a.Baremachineb.Single-usersystemc.Multiprogrammingwithafixednumberofprocessesd.Multiprogrammingwithavariablenumberofprocessese.Pagingf.Segmentationa.Protectionnotnecessary,setsystemkeyto0.b.Setsystemkeyto0wheninsupervisormode.c.Regionsizesmustbefixedinincrementsof2kbytes,allocatekeywithmemoryblocks.d.Sameasabove.e.Framesizesmustbeinincrementsof2kbytes,allocatekeywithpages.f.Segmentsizesmustbeinincrementsof2kbytes,allocatekeywithsegments.第5頁Chapter1010.1Underwhatcircumstancesdopagefaultsoccur?Describetheactionstakenbytheoperatingsystemwhenapagefaultoccurs.Apagefaultoccurswhenanaccesstoapagethathasnotbeenbroughtintomainmemorytakesplace.Theoperatingsystemverifiesthememoryaccess,abortingtheprogramifitisinvalid.Ifitisvalid,afreeframeislocatedandI/Oisrequestedtoreadtheneededpageintothefreeframe.UponcompletionofI/O,theprocesstableandpagetableareupdatedandtheinstructionisrestarted.第6頁10-cont.10.6Considerthefollowingreplacementalgorithms.Rankthesealgorithmsonafivepointscalefrom“bad”to“perfect”accordingtotheirfaultrate.SeparatethosealgorithmsthatsufferfromBelady’sanomalyfromthosethatdonot.a.LRUreplacementb.FIFOreplacementc.Optimalreplacementd.Second-chancereplacementRankAlgorithmSufferfromBelady’sanomaly1Optimalno2LRUno3Second-chanceyes4FIFOyes第7頁10-cont.10.9Considerademand-pagingsystemwiththefollowingtime-measuredutilizations:CPUutilization20%Pagingdisk97.7%OtherI/Odevices5%Which(ifany)ofthefollowingwill(probably)improveCPUutilization?Explainyouranswer.a.InstallafasterCPU.b.Installabiggerpagingdisk.c.Increasethedegreeofmultiprogramming.d.Decreasethedegreeofmultiprogramming.e.Installmoremainmemory.f.Installafasterharddiskormultiplecontrollerswithmultipleharddisks.g.Addprepagingtothepagefetchalgorithms.h.Increasethepagesize.第8頁10-cont.10.10Considerthetwo-dimensionalarrayA:intA[][]=newint[100][100];whereA[0][0]isatlocation200,inapagedsystemwithpagesofsize200.Asmallprocessisinpage0(locations0to199)formanipulatingthematrix;thus,everyinstructionfetchwillbefrompage0.Forthreepageframes,howmanypagefaultsaregeneratedbythefollowingarray-initializationloops,usingLRUreplacement,andassumingpageframe1hastheprocessinit,andtheothertwoareinitiallyempty:a.for(intj=0;j<100;j++)for(inti=0;i<100;i++)A[i][j]=0;b.for(inti=0;i<100;i++)for(intj=0;j<100;j++)A[i][j]=0;a.100x50b.50第9頁10-cont.10.11Considerthefollowingpagereferencestring: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.LRUreplacementFIFOreplacementOptimalreplacementNumberofframesLRUFIFOOptimal12020202181815315161141014858107671077777第10頁Chapter1111.3Whydosomesystemskeeptrackofthetypeofafile,whileothersleaveittotheuserorsimplydonotimplementmultiplefiletypes?Whichsystemis“better?”Somesystemsallowdifferentfileoperationsbasedonthetypeofthefile(forinstance,anasciifilecanbereadasastreamwhileadatabasefilecanbereadviaanindextoablock).Othersystemsleavesuchinterpretationofafile’sdatatotheprocessandprovidenohelpinaccessingthedata.Themethodwhichis“better”dependsontheneedsoftheprocessesonthesystem,andthedemandstheusersplaceontheoperatingsystem.Ifasystemrunsmostlydatabaseapplications,itmaybemoreefficientfortheoperatingsystemtoimplementadatabase-typefileandprovideoperations,ratherthanmakingeachprogramimplementthesamething(possiblyindifferentways).Forgeneralpurposesystemsitmaybebettertoonlyimplementbasicfiletypestokeeptheoperatingsystemsizesmallerandallowmaximumfreedomtotheprocessesonthesystem.第11頁11-cont.11.6Couldyousimulateamultileveldirectorystructurewithasingle-leveldirectorystructureinwhicharbitrarilylongnamescanbeused?Ifyouranswerisyes,explainhowyoucandoso,andcontrastthisschemewiththemultileveldirectoryscheme.Ifyouranswerisno,explainwhatpreventsyoursimulation’ssuccess.Howwouldyouranswerchangeiffilenameswerelimitedtosevencharacters?Ifarbitrarilylongnamescanbeusedthenitispossibletosimulateamultileveldirectorystructure.Thiscanbedone,forexample,byusingthecharacter“.”toindicatetheendofasubdirectory.Thus,forexample,thenamejim.pascal.F1specifiesthatF1isafileinsubdirectorypascalwhichinturnisintherootirectoryjim.Iffilenameswerelimitedtosevencharacters,thentheaboveschemecouldnotbeutilizedandthus,ingeneral,theanswerisno.Thenextbestapproachinthissituationwouldbetouseaspecificfileasasymboltable(directory)tomaparbitrarilylongnames(suchasjim.pascal.F1)intoshorterarbitrarynames(suchasXX00743),whicharethenusedforactualfileaccess.第12頁11-cont.11.9Giveanexampleofanapplicationinwhichdatainafileshouldbeaccessedinthefollowingorder:a.Sequentiallyb.Randomlya.Printthecontentofthefile.b.Printthecontentofrecordi.Thisrecordcanbefoundusinghashingorindextechniques.11.12Considerasystemthatsupports5000users.Supposethatyouwanttoallow4990oftheseuserstobeabletoaccessonefile.a.HowwouldyouspecifythisprotectionschemeinUNIX?b.CouldyousuggestanotherprotectionschemethatcanbeusedmoreeffectivelyforthispurposethantheschemeprovidedbyUNIX?a.Therearetwomethodsforachievingthis:i.Createanaccesscontrollistwiththenamesofall4990users.ii.Putthese4990usersinonegroupandsetthegroupaccessaccordingly.Thisschemecannotalwaysbeimplementedsinceusergroupsarerestrictedbythesystem.b.Theuniverseaccessinformationappliestoallusersunlesstheirnameappearsintheaccess-controllistwithdifferentaccesspermission.Withthisschemeyousimplyputthenamesoftheremainingtenusersintheaccesscontrollistbutwithnoaccessprivilegesallowed.第13頁Chapter1212.1Considerafilecurrentlyconsistingof100blocks.Assumethatthefilecontrolblock(andtheindexblock,inthecaseofindexedallocation)isalreadyinmemory.CalculatehowmanydiskI/Ooperationsarerequiredforcontiguous,linked,andindexed(single-level)allocationstrategies,if,foroneblock,thefollowingconditionshold.Inthecontiguousallocationcase,assumethatthereisnoroomtogrowinthebeginning,butthereisroomtogrowintheend.Assumethattheblockinformationtobeaddedisstoredinmemory.a.Theblockisaddedatthebeginning.b.Theblockisaddedinthemiddle.c.Theblockisaddedattheend.d.Theblockisremovedfromthebeginning.e.Theblockisremovedfromthemiddle.f.Theblockisremovedfromtheend.ContiguousLinkedIndexed201(100讀寫+1新寫)1(1新寫)1(1新寫)101(50讀寫+1新寫)52(50讀+第50塊寫+1新寫)1(1新寫)1(1新寫)3(第100塊讀寫+1新寫)1(1新寫)198(99讀寫)1(讀第1塊)098(后49塊讀寫)52(51讀+第50塊寫)00100(99讀+1寫)0第14頁12-cont.12.2Considerasystemwherefreespaceiskeptinafree-spacelist.a.Supposethatthepointertothefree-spacelistislost.Canthesystemreconstructthefree-spacelist?Explainyouranswer.b.Suggestaschemetoensurethatthepointerisneverlostasaresultofmemoryfailure.a.Inordertoreconstructthefreelist,itwouldbenecessarytoperform“garbagecollection.”Thiswouldentailsearchingtheentiredirectorystructuretodeterminewhichpagesarealreadyallocatedtojobs.Thoseremainingunallocatedpagescouldberelinkedasthefree-spacelist.b.Thefree-spacelistpointercouldbestoredonthedisk,perhapsinseveralplaces.第15頁12-cont.12.3Whatproblemscouldoccurifasystemallowedafilesystemtobemountedsimultaneouslyatmorethanonelocation?Therewouldbemultiplepathstothesamefile,whichcouldconfuseusersorencouragemistakes(deletingafilewithonepathdeletesthefileinalltheotherpaths).12.4Whymustthebitmapforfileallocationbekeptonmassstorage,ratherthaninmainmemory?Incaseofsystemcrash(memoryfailure)thefree-spacelistwouldnotbelostasitwouldbeifthebitmaphadbeenstoredinmainmemory.第16頁12-cont.12.5Considerasystemthatsupportsthestrategiesofcontiguous,linked,andindexedallocation.Whatcriteriashouldbeusedindecidingwhichstrategyisbestutilizedforaparticularfile?Contiguous–iffileisusuallyaccessedsequentially,iffileisrelativelysmall.
Linked–iffileislargeandusuallyaccessedsequentially.
Indexed–iffileislargeandusuallyaccessedrandomly.12.6Considerafilesystemonadiskthathasbothlogicalandphysicalblocksizesof512bytes.Assumethattheinformationabouteachfileisalreadyinmemory.Foreachofthethreeallocationstrategies(contiguous,linked,andindexed),answerthesequestions:a.Howisthelogical-to-physicaladdressmappingaccomplishedinthissystem?(Fortheindexedallocation,assumethatafileisalwayslessthan512blockslong.)b.Ifwearecurrentlyatlogicalblock10(thelastblockaccessedwasblock10)andwanttoaccesslogicalblock4,howmanyphysicalblocksmustbereadfromthedisk?a.Contiguous.Dividethelogicaladdressby512withXandYtheresultingquotientandremainderrespectively.i.AddXtoZtoobtainthephysicalblocknumber.Yisthedisplacementintothatblock.ii.1b.Linked.Dividethelogicalphysicaladdressby511withXandYtheresultingquotientandremainderrespectively.i.Chasedownthelinkedlist(gettingX+1blocks).Y+1isthedisplacementintothelastphysicalblock.ii.4c.Indexed.Dividethelogicaladdressby512withXandYtheresultingquotientandremainderrespectively.i.Gettheindexblockintomemory.PhysicalblockaddressiscontainedintheindexblockatlocationX.Yisthedisplacementintothedesiredphysicalblock.ii.2第17頁Chapter1313.1Statethreeadvantagesofplacingfunctionalityinadevicecontroller,ratherthaninthekernel.Statethreedisadvantages.Threeadvantages:BugsarelesslikelytocauseanoperatingsystemcrashPerformancecanbeimprovedbyutilizingdedicatedhardwareandhard-codedalgorithmsThekernelissimplifiedbymovingalgorithmsoutofitThreedisadvantages:Bugsarehardertofix-anewfirmwareversionornewhardwareisneededImprovingalgorithmslikewiserequireahardwareupdateratherthanjustkernelordevicedriverupdateEmbeddedalgorithmscouldconflictwithapplication’suseofthedevice,causingdecreasedperformance.第18頁13-cont.13.2ConsiderthefollowingI/Oscenariosonasingle-userPC.a.Amouseusedwithagraphicaluserinterfaceb.Atapedriveonamultitaskingoperatingsystem(assumenodevicepreallocationisavailable)c.Adiskdrivecontaininguserfilesd.Agraphicscardwithdirectbusconnection,accessiblethroughmemory-mappedI/OForeachoftheseI/Oscenarios,wouldyoudesigntheoperatingsystemtousebuffering,spooling,caching,oracombination?WouldyouusepolledI/O,orinterrupt-drivenI/O?Givereasonsforyourchoices.a.Bufferingmaybeneededtorecordmousemovementduringtimeswhenhigherpriorityoperationsaretakingplace.Spoolingandcachingareinappropriate.InterruptdrivenI/Oismostappropriate.b.BufferingmaybeneededtomanagethroughputdifferencebetweenthetapedriveandthesourceordestinationoftheI/O,Cachingcanbeusedtoholdcopiesofdatathatresidesonthetape,forfasteraccess.Spoolingcouldbeusedtostagedatatothedevicewhenmultipleusersdesiretoreadfromorwritetoit.InterruptdrivenI/Oislikelytoallowthebestperformance.c.Bufferingcanbeusedtoholddatawhileintransitfromuserspacetothedisk,andvisaversa.Cachingcanbeusedtoholddisk-residentdataforimprovedperformance.Spoolingisnotnecessarybecausedisksareshared-accessdevices.InterruptdrivenI/Oisbestfordevicessuchasdisksthattransferdataatslowrates.d.Bufferingmaybeneededtocontrolmultipleaccessandforperformance(doublebufferingcanbeusedtoholdthenextscreenimagewhiledisplayingthecurrentone).Cachingandspoolingarenotnecessaryduetothefastandshared-accessnaturesofthedevice.PollingandinterruptsareonlyusefulforinputandforI/Ocompletiondetection,neitherofwhichisneededforamemory-mappeddevice.第19頁13-cont.13.4DescribethreecircumstancesunderwhichblockingI/Oshouldbeused.DescribethreecircumstancesunderwhichnonblockingI/Oshouldbeused.WhynotjustimplementnonblockingI/Oandhaveprocessesbusy-waituntiltheirdeviceisready?Generally,blockingI/Oisappropriatewhentheprocesswillonlybewaitingforonespecificevent.Examplesincludeadisk,tape,orkeyboardreadbyanapplicationprogram.Non-blockingI/OisusefulwhenI/OmaycomefrommorethanonesourceandtheorderoftheI/Oarrivalisnotpredetermined.Examplesincludenetworkdaemonslisteningtomorethanonenetworksocket,windowmanagersthatacceptmousemovementaswellaskeyboardinput,andI/O-managementprograms,suchasacopycommandthatcopiesdatabetweenI/Odevices.Inthelastcase,theprogramcouldoptimizeitsperformancebybufferingtheinputandoutputandusingnon-blockingI/Otokeepbothdevicesfullyoccupied.Non-blockingI/Oismorecomplicatedforprogrammers,becauseoftheasynchonousrendezvousthatisneededwhenanI/Ooccurs.Also,busywaitingislessefficientthaninterrupt-drivenI/Osotheoverallsystemperformancewoulddecrease.第20頁13-cont.13.5Whymightasystemuseinterrupt-drivenI/Otomanageasingleserialport,butpollingI/Otomanageafront-endprocessor,suchasaterminalconcentrator?Pollingcanbemoreefficientthaninterrupt-drivenI/O.ThisisthecasewhentheI/Oisfrequentandofshortduration.EventhoughasingleserialportwillperformI/Orelativelyinfrequentlyandshouldthususeinterrupts,acollectionofserialportssuchasthoseinaterminalconcentratorcanproducealotofshortI/Ooperations,andinterruptingforeachonecouldcreateaheavyloadonthesystem.Awell-timedpollingloopcouldalleviatethatloadwithoutwastingmanyresourcesthroughloopingwithnoI/Oneeded.13.8HowdoesDMAincreasesystemconcurrency?Howdoesitcomplicatehardwaredesign?DMAincreasessystemconcurrencybyallowingtheCPUtoperformtaskswhiletheDMAsystemtransfersdataviathesystemandmemorybusses.HardwaredesigniscomplicatedbecausetheDMAcontrollermustbeintegratedintothesystem,andthesystemmustallowtheDMAcontrollertobeabusmaster.CyclestealingmayalsobenecessarytoallowtheCPUandDMAcontrollertoshareuseofthememorybus.第21頁Chapter1414.2Supposethatadiskdrivehas5000cylinders,numbered0to4999.Thedriveiscurrentlyservingarequestatcylinder143,andthepreviousrequestwasatcylinder125.Thequeueofpendingrequests,inFIFOorder,is86,1470,913,1774,948,1509,1022,1750,130Startingfromthecurrentheadposition,whatisthetotaldistance(incylinders)thatthediskarmmovestosatisfyallthependingrequests,foreachofthefollowingdiskschedulingalgorithms?a.FCFSb.SSTFc.SCANd.LOOKe.C-SCANa.TheFCFSscheduleis143,86,1470,913,1774,948,1509,1022,1750,130.Thetotalseekdistanceis7081.b.TheSSTFscheduleis143,130,86,913,948,1022,1470,1509,1750,1774.Thetotalse
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 書行業(yè)中標(biāo)合同樣本
- 人防車位購買合同樣本
- 鄉(xiāng)村河道橋梁承建合同標(biāo)準文本
- lpr利率貸款合同樣本
- 公司承包飛機合同樣本
- 修路工程合伙合同標(biāo)準文本
- 幼兒園科學(xué)活動教案
- 串貨合同標(biāo)準文本標(biāo)準文本
- 年部編版小學(xué)語文六年級上冊教案設(shè)計全冊
- 世界的人口教案
- 固體飲料生產(chǎn)許可證審查細則
- 三年級下冊綜合實踐活動課件-水果拼盤 全國通用(共15張PPT)
- 污水池內(nèi)防腐施工方案
- 關(guān)于對領(lǐng)導(dǎo)班子的意見和建議
- 火警火災(zāi)處理標(biāo)準流程
- TCCIAT 0043-2022 建筑工程滲漏治理技術(shù)規(guī)程
- 初中美術(shù)七年級下冊《第4課扮靚生活的花卉紋樣》課件
- 土建、裝飾、維修改造等零星工程施工組織方案設(shè)計技術(shù)標(biāo)范文
- 宮頸癌病歷書寫模板
- 芭蕾基訓(xùn)課程課時教案
- T∕CIC 049-2021 水泥窯用固體替代燃料
評論
0/150
提交評論