您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > 现代操作系统(第三版)答案
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
本文标题:现代操作系统(第三版)答案
链接地址:https://www.777doc.com/doc-6988540 .html