+第三版++答桉.docx

上传人:b****5 文档编号:30702106 上传时间:2023-08-19 格式:DOCX 页数:35 大小:43.12KB
下载 相关 举报
+第三版++答桉.docx_第1页
第1页 / 共35页
+第三版++答桉.docx_第2页
第2页 / 共35页
+第三版++答桉.docx_第3页
第3页 / 共35页
+第三版++答桉.docx_第4页
第4页 / 共35页
+第三版++答桉.docx_第5页
第5页 / 共35页
点击查看更多>>
下载资源
资源描述

+第三版++答桉.docx

《+第三版++答桉.docx》由会员分享,可在线阅读,更多相关《+第三版++答桉.docx(35页珍藏版)》请在冰豆网上搜索。

+第三版++答桉.docx

+第三版++答桉

SOLUTIONSTOCHAPTER1PROBLEMS

1.Anoperatingsystemmustprovidetheuserswithanextended(i.e.,virtual)machine,anditmustmanagetheI/Odevicesandothersystemresources.

2.MultiprogrammingistherapidswitchingoftheCPUbetweenmultipleprocessesinmemory.ItiscommonlyusedtokeeptheCPUbusywhileoneormoreprocessesaredoingI/O.

3.Inputspoolingisthetechniqueofreadinginjobs,forexample,fromcards,ontothedisk,sothatwhenthecurrentlyexecutingprocessesarefinished,therewillbeworkwaitingfortheCPU.Outputspoolingconsistsoffirstcopyingprintablefilestodiskbeforeprintingthem,ratherthanprintingdirectlyastheoutputisgenerated.

Acronymforsimultaneousperipheraloperationson-line,spoolingreferstoputtingjobsinabuffer,aspecialareainmemoryoronadiskwhereadevicecanaccessthemwhenitisready.

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.

Producememorybank

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.Thenitwouldgototheinterruptvectorfor

theinterruptingdeviceandfetchapointertoanotherprocesstableentry(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.Thisprocess

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 考试认证 > IT认证

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1