现代操作系统(第三版)答案

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

MODERNOPERATINGSYSTEMSTHIRDEDITIONPROBLEMSOLUTIONSANDREWS.TANENBAUMVrijeUniversiteitAmsterdam,TheNetherlandsPRENTICEHALLUPPERSADDLERIVER,NJ07458CopyrightPearsonEducation,Inc.2008SOLUTIONSTOCHAPTER1PROBLEMS1.MultiprogrammingistherapidswitchingoftheCPUbetweenmultipleproc-essesinmemory.ItiscommonlyusedtokeeptheCPUbusywhileoneormoreprocessesaredoingI/O.2.Inputspoolingisthetechniqueofreadinginjobs,forexample,fromcards,ontothedisk,sothatwhenthecurrentlyexecutingprocessesarefinished,therewillbeworkwaitingfortheCPU.Outputspoolingconsistsoffirstcopyingprintablefilestodiskbeforeprintingthem,ratherthanprintingdi-rectlyastheoutputisgenerated.Inputspoolingonapersonalcomputerisnotverylikely,butoutputspoolingis.3.TheprimereasonformultiprogrammingistogivetheCPUsomethingtodowhilewaitingforI/Otocomplete.IfthereisnoDMA,theCPUisfullyoccu-pieddoingI/O,sothereisnothingtobegained(atleastintermsofCPUutili-zation)bymultiprogramming.NomatterhowmuchI/Oaprogramdoes,theCPUwillbe100%busy.Thisofcourseassumesthemajordelayisthewaitwhiledataarecopied.ACPUcoulddootherworkiftheI/Owereslowforotherreasons(arrivingonaserialline,forinstance).4.Itisstillalive.Forexample,IntelmakesPentiumI,II,andIII,and4CPUswithavarietyofdifferentpropertiesincludingspeedandpowerconsumption.Allofthesemachinesarearchitecturallycompatible.Theydifferonlyinpriceandperformance,whichistheessenceofthefamilyidea.5.A25×80charactermonochrometextscreenrequiresa2000-bytebuffer.The1024×768pixel24-bitcolorbitmaprequires2,359,296bytes.In1980thesetwooptionswouldhavecost$10and$11,520,respectively.Forcurrentprices,checkonhowmuchRAMcurrentlycosts,probablylessthan$1/MB.6.Considerfairnessandrealtime.Fairnessrequiresthateachprocessbeallo-cateditsresourcesinafairway,withnoprocessgettingmorethanitsfairshare.Ontheotherhand,realtimerequiresthatresourcesbeallocatedbasedonthetimeswhendifferentprocessesmustcompletetheirexecution.Areal-timeprocessmaygetadisproportionateshareoftheresources.7.Choices(a),(c),and(d)shouldberestrictedtokernelmode.8.Itmaytake20,25or30msectocompletetheexecutionoftheseprogramsdependingonhowtheoperatingsystemschedulesthem.IfP0andP1arescheduledonthesameCPUandP2isscheduledontheotherCPU,itwilltake20mses.IfP0andP2arescheduledonthesameCPUandP1isscheduledontheotherCPU,itwilltake25msec.IfP1andP2arescheduledonthesameCPUandP0isscheduledontheotherCPU,itwilltake30msec.IfallthreeareonthesameCPU,itwilltake35msec.2PROBLEMSOLUTIONSFORCHAPTER19.Everynanosecondoneinstructionemergesfromthepipeline.Thismeansthemachineisexecuting1billioninstructionspersecond.Itdoesnotmatteratallhowmanystagesthepipelinehas.A10-stagepipelinewith1nsecperstagewouldalsoexecute1billioninstructionspersecond.Allthatmattersishowoftenafinishedinstructionpopsouttheendofthepipeline.10.Averageaccesstime=0.95×2nsec(wordiscache)+0.05×0.99×10nsec(wordisinRAM,butnotincache)+0.05×0.01×10,000,000nsec(wordondiskonly)=5002.395nsec=5.002395μsec11.Themanuscriptcontains80×50×700=2.8millioncharacters.Thisis,ofcourse,impossibletofitintotheregistersofanycurrentlyavailableCPUandistoobigfora1-MBcache,butifsuchhardwarewereavailable,themanuscriptcouldbescannedin2.8msecfromtheregistersor5.8msecfromthecache.Thereareapproximately27001024-byteblocksofdata,soscan-ningfromthediskwouldrequireabout27seconds,andfromtape2minutes7seconds.Ofcourse,thesetimesarejusttoreadthedata.Processingandrewritingthedatawouldincreasethetime.12.Maybe.Ifthecallergetscontrolbackandimmediatelyoverwritesthedata,whenthewritefinallyoccurs,thewrongdatawillbewritten.However,ifthedriverfirstcopiesthedatatoaprivatebufferbeforereturning,thenthecallercanbeallowedtocontinueimmediately.Anotherpossibilityistoallowthecallertocontinueandgiveitasignalwhenthebuffermaybereused,butthisistrickyanderrorprone.13.AtrapinstructionswitchestheexecutionmodeofaCPUfromtheusermodetothekernelmode.Thisinstructionallowsauserprogramtoinvokefunc-tionsintheoperatingsystemkernel.14.Atrapiscausedbytheprogramandissynchronouswithit.Iftheprogramisrunagainandagain,thetrapwillalwaysoccuratexactlythesamepositionintheinstructionstream.Aninterruptiscausedbyanexternaleventanditstimingisnotreproducible.15.Theprocesstableisneededtostorethestateofaprocessthatiscurrentlysuspended,eitherreadyorblocked.Itisnotneededinasingleprocesssys-tembecausethesingleprocessisneversuspended.16.Mountingafilesystemmakesanyfilesalreadyinthemountpointdirectoryinaccessible,somountpointsarenormallyempty.However,asystemadmin-istratormightwanttocopysomeofthemostimportantfilesnormallylocatedinthemounteddirectorytothemountpointsotheycouldbefoundintheirnormalpathinanemergencywhenthemounteddevicewasbeingrepaired.PROBLEMSOLUTIONSFORCHAPTER1317.Asystemcallallowsauserprocesstoaccessandexecuteoperatingsystemfunctionsinsidethekernel.Userprogramsusesystemcallstoinvokeoperat-ingsystemservices.18.Forkcanfailiftherearenofreeslotsleftintheprocesstable(andpossiblyifthereisnomemoryorswapspaceleft).Execcanfailifthefilenamegivendoesnotexistorisnotavalidexecutablefile.Unlinkcanfailifthefiletobeunlinkeddoesnotexistorthecallingprocessdoesnothavetheauthoritytounlinkit.19.If

1 / 65
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功