现代操作系统第三版答案.docx
- 文档编号:7618714
- 上传时间:2023-01-25
- 格式:DOCX
- 页数:64
- 大小:265.50KB
现代操作系统第三版答案.docx
《现代操作系统第三版答案.docx》由会员分享,可在线阅读,更多相关《现代操作系统第三版答案.docx(64页珍藏版)》请在冰豆网上搜索。
现代操作系统第三版答案
SOLUTIONSTOCHAPTER1PROBLEMS
1.Anoperatingsystemmustprovidetheuserswithanextended(i.e.,virtual)machine,anditmustmanagetheI/Odevicesandothersystemresources.
2.MultiprogrammingistherapidswitchingoftheCPUbetweenmultipleprocessesinmemory.ItiscommonlyusedtokeeptheCPUbusywhileoneormoreprocessesaredoingI/O.
3.Inputspoolingisthetechniqueofreadinginjobs,forexample,fromcards,ontothedisk,sothatwhenthecurrentlyexecutingprocessesarefinished,therewillbeworkwaitingfortheCPU.Outputspoolingconsistsoffirstcopyingprintablefilestodiskbeforeprintingthem,ratherthanprintingdirectlyastheoutputisgenerated.Inputspoolingonapersonalcomputerisnotverylikely,butoutputspoolingis.
4.
TheprimereasonformultiprogrammingistogivetheCPUsomethingtodowhilewaitingforI/Otocomplete.IfthereisnoDMA,theCPUisfullyoccupieddoingI/O,sothereisnothingtobegained(atleastintermsofCPUutilization)bymultiprogramming.NomatterhowmuchI/Oaprogramdoes,theCPUwillbe100percentbusy.Thisofcourseassumesthemajordelayisthewaitwhiledataarecopied.ACPUcoulddootherworkiftheI/Owereslowforotherreasons(arrivingonaserialline,forinstance).
5.Secondgenerationcomputersdidnothavethenecessaryhardwaretoprotecttheoperatingsystemfrommalicioususerprograms.
6.Itisstillalive.Forexample,IntelmakesPentiumI,II,andIII,and4CPUswithavarietyofdifferentpropertiesincludingspeedandpowerconsumption.Allofthesemachinesarearchitecturallycompatible.Theydifferonlyinpriceandperformance,whichistheessenceofthefamilyidea.
7.A25×80charactermonochrometextscreenrequiresa2000-bytebuffer.The1024×768pixel24-bitcolorbitmaprequires2,359,296bytes.In1980thesetwooptionswouldhavecost$10and$11,520,respectively.Forcurrentprices,checkonhowmuchRAMcurrentlycosts,probablylessthan$1/MB.
8.Choices(a),(c),and(d)shouldberestrictedtokernelmode.
9.Personalcomputersystemsarealwaysinteractive,oftenwithonlyasingleuser.Mainframesystemsnearlyalwaysemphasizebatchortimesharingwithmanyusers.Protectionismuchmoreofanissueonmainframesystems,asisefficientuseofallresources.
10.Everynanosecondoneinstructionemergesfromthepipeline.Thismeansthemachineisexecuting1billioninstructionspersecond.Itdoesnotmatteratallhowmanystagesthepipelinehas.A10-stagepipelinewith1nsecperstagewouldalsoexecute1billioninstructionspersecond.Allthatmattersishowoftenafinishedinstructionspopsouttheendofthepipeline.
11.
Themanuscriptcontains80×50×700=2.8millioncharacters.Thisis,ofcourse,impossibletofitintotheregistersofanycurrentlyavailableCPUandistoobigfora1-MBcache,butifsuchhardwarewereavailable,themanuscriptcouldbescannedin2.8msecfromtheregistersor5.8msecfromthecache.Thereareapproximately27001024-byteblocksofdata,soscanningfromthediskwouldrequireabout27seconds,andfromtape2minutes7seconds.Ofcourse,thesetimesarejusttoreadthedata.Processingandrewritingthedatawouldincreasethetime.
12.Logically,itdoesnotmatterifthelimitregisterusesavirtualaddressoraphysicaladdress.However,theperformanceoftheformerisbetter.Ifvirtualaddressesareused,theadditionofthevirtualaddressandthebaseregistercanstartsimultaneouslywiththecomparisonandthencanruninparallel.Ifphysicaladdressesareused,thecomparisoncannotstartuntiltheadditioniscomplete,increasingtheaccesstime.
13.Maybe.Ifthecallergetscontrolbackandimmediatelyoverwritesthedata,whenthewritefinallyoccurs,thewrongdatawillbewritten.However,ifthedriverfirstcopiesthedatatoaprivatebufferbeforereturning,thenthecallercanbeallowedtocontinueimmediately.Anotherpossibilityistoallowthecallertocontinueandgiveitasignalwhenthebuffermaybereused,butthisistrickyanderrorprone.
14.Atrapiscausedbytheprogramandissynchronouswithit.Iftheprogramisrunagainandagain,thetrapwillalwaysoccuratexactlythesamepositionintheinstructionstream.Aninterruptiscausedbyanexternaleventanditstimingisnotreproducible.
15.Base=40,000andlimit=10,000.Anansweroflimit=50,000isincorrectforthewaythesystemwasdescribedinthisbook.Itcouldhavebeenimplementedthatway,butdoingsowouldhaverequiredwaitinguntiltheaddress+basecalculationwascompletedbeforestartingthelimitcheck,thusslowingdownthecomputer.
16.Theprocesstableisneededtostorethestateofaprocessthatiscurrentlysuspended,eitherreadyorblocked.Itisnotneededinasingleprocesssystembecausethesingleprocessisneversuspended.
17.Mountingafilesystemmakesanyfilesalreadyinthemountpointdirectoryinaccessible,somountpointsarenormallyempty.However,asystemadministratormightwanttocopysomeofthemostimportantfilesnormallylocatedinthemounteddirectorytothemountpointsotheycouldbefoundintheirnormalpathinanemergencywhenthemounteddevicewasbeingcheckedorrepaired.
18.Forkcanfailiftherearenofreeslotsleftintheprocesstable(andpossiblyifthereisnomemoryorswapspaceleft).Execcanfailifthefilenamegivendoesnotexistorisnotavalidexecutablefile.Unlinkcanfailifthefiletobeunlinkeddoesnotexistorthecallingprocessdoesnothavetheauthoritytounlinkit.
19.Ifthecallfails,forexamplebecausefdisincorrect,itcanreturn−1.Itcanalsofailbecausethediskisfullanditisnotpossibletowritethenumberofbytesrequested.Onacorrecttermination,italwaysreturnsnbytes.
20.Itcontainsthebytes:
1,5,9,2.
21.Blockspecialfilesconsistofnumberedblocks,eachofwhichcanbereadorwrittenindependentlyofalltheotherones.Itispossibletoseektoanyblockandstartreadingorwriting.Thisisnotpossiblewithcharacterspecialfiles.
22.Systemcallsdonotreallyhavenames,otherthaninadocumentationsense.Whenthelibraryprocedurereadtrapstothekernel,itputsthenumberofthesystemcallinaregisteroronthestack.Thisnumberisusedtoindexintoatable.Thereisreallynonameusedanywhere.Ontheotherhand,thenameofthelibraryprocedureisveryimportant,sincethatiswhatappearsintheprogram.
23.Yesitcan,especiallyifthekernelisamessage-passingsystem.
24.
Asfarasprogramlogicisconcerneditdoesnotmatterwhetheracalltoalibraryprocedureresultsinasystemcall.Butifperformanceisanissue,ifataskcanbeaccomplishedwithoutasystemcalltheprogramwillrunfaster.Everysystemcallinvolvesoverheadtimeinswitchingfromtheusercontexttothekernelcontext.Furthermore,onamultiusersystemtheoperatingsystemmayscheduleanotherprocesstorunwhenasystemcallcompletes,furtherslowingtheprogressinrealtimeofacallingprocess.
25.SeveralUNIXcallshavenocounterpartintheWin32API:
Link:
aWin32programcannotrefertoafilebyanalternatenameorseeitinmorethanonedirectory.Also,attemptingtocreatealinkisaconvenientwaytotestforandcreatealockonafile.
Mountandumount:
aWindowsprogramcannotmakeassumptionsaboutstandardpathnamesbecauseonsystemswithmultiplediskdrivesthedrivenamepartofthepathmaybedifferent.
Chmod:
Windowsprogrammershavetoassumethateveryusercanaccesseveryfile.
Kill:
Windowsprogrammerscannotkillamisbehavingprogramthatisnotcooperating.
26.Theconversionsarestraightforward:
(a)Amicroyearis10−6×365×24×3600=31.536sec.
(b)1000metersor1km.
(c)Thereare240bytes,whichis1,099,511,627,776bytes.(d)Itis6×1024kg.
SOLUTIONSTOCHAPTER2PROBLEMS
1.Thetransitionfromblockedtorunningisconceivable.SupposethataprocessisblockedonI/OandtheI/Ofinishes.IftheCPUisotherwiseidle,theprocesscouldgodirectlyfromblockedtorunning.Theothermissingtransition,fromreadytoblocked,isimpossible.AreadyprocesscannotdoI/Ooranythingelsethatmightblockit.Onlyarunningprocesscanblock.
2.Youcouldhavearegistercontainingapointertothecurrentprocesstableentry.WhenI/Ocompleted,theCPUwouldstorethecurrentmachinestateinthecurrentprocesstableentry.Thenitwouldgototheinterruptvectorfortheinterruptingdeviceandfetchapointertoanotherprocesstableentry(theserviceprocedure).Thisprocesswouldthenbestartedup.
3.Generally,high-levellanguagesdonotallowonethekindofaccesstoCPUhardwarethatisrequired.Forinstance,aninterrupthandlermayberequiredtoenableanddisabletheinterruptservicingaparticulardevice,ortomanipulatedatawithinaprocess’stackarea.Also,interruptserviceroutinesmustexecuteasrapidlyaspossible.
4.
Thereareseveralreasonsforusingaseparatestackforthekernel.Twoofthemareasfollows.First,youdonotwanttheoperatingsystemtocrashbecauseapoorlywrittenuserprogramdoesnotallowforenoughstackspace.Second,ifthekernelleavesstackdatainauserprogram’smemoryspaceuponreturnfromasystemcall,amalicioususermightbeabletousethisdatatofindoutinformationaboutotherprocesses.
5.Itwouldbedifficult,ifnotimpossible,tokeepthefilesystemconsistent.Supposethataclientprocesssendsarequesttoserverprocess1toupdateafile.Thisprocessupdatesthecacheentryinitsmemory.Shortlythereafter,anotherclientprocesssendsarequesttoserver2toreadthatfile.Unfortunately,ifthefileisalsocachedthere,server2
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 现代 操作系统 第三 答案