操作系统设计与实现课后习题答案(英文)

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

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

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

资源描述

OPERATINGSYSTEMS:DESIGNANDIMPLEMENTATIONTHIRDEDITIONPROBLEMSOLUTIONSANDREWS.TANENBAUMVrijeUniversiteitAmsterdam,TheNetherlandsALBERTS.WOODHULLAmherst,MassachusettsPRENTICEHALLUPPERSADDLERIVER,NJ07458SOLUTIONSTOCHAPTER1PROBLEMS1.Anoperatingsystemmustprovidetheuserswithanextended(i.e.,virtual)machine,anditmustmanagetheI/Odevicesandothersystemresources.2.Inkernelmode,everymachineinstructionisallowed,asisaccesstoalltheI/Odevices.Inusermode,manysensitiveinstructionsareprohibited.Operatingsystemsusethesetwomodestoencapsulateuserprograms.Run-ninguserprogramsinusermodekeepsthemfromdoingI/Oandpreventsthemfrominterferingwitheachotherandwiththekernel.3.MultiprogrammingistherapidswitchingoftheCPUbetweenmultipleprocessesinmemory.ItiscommonlyusedtokeeptheCPUbusywhileoneormoreprocessesaredoingI/O.4.Inputspoolingisthetechniqueofreadinginjobs,forexample,fromcards,ontothedisk,sothatwhenthecurrentlyexecutingprocessesarefinished,therewillbeworkwaitingfortheCPU.Outputspoolingconsistsoffirstcopyingprintablefilestodiskbeforeprintingthem,ratherthanprintingdirectlyastheoutputisgenerated.Inputspoolingonapersonalcomputerisnotverylikely,butoutputspoolingis.5.TheprimereasonformultiprogrammingistogivetheCPUsomethingtodowhilewaitingforI/Otocomplete.IfthereisnoDMA,theCPUisfullyoccu-pieddoingI/O,sothereisnothingtobegained(atleastintermsofCPUutili-zation)bymultiprogramming.NomatterhowmuchI/Oaprogramdoes,theCPUwillbe100percentbusy.Thisofcourseassumesthemajordelayisthewaitwhiledataiscopied.ACPUcoulddootherworkiftheI/Owereslowforotherreasons(arrivingonaserialline,forinstance).6.Secondgenerationcomputersdidnothavethenecessaryhardwaretoprotecttheoperatingsystemfrommalicioususerprograms.7.Choices(a),(c),and(d)shouldberestrictedtokernelmode.8.Personalcomputersystemsarealwaysinteractive,oftenwithonlyasingleuser.Mainframesystemsnearlyalwaysemphasizebatchortimesharingwithmanyusers.Protectionismuchmoreofanissueonmainframesystems,asisefficientuseofallresources.9.Argumentsforclosedsourcearethatthecompanycanvettheprogrammers,establishprogrammingstandards,andenforceadevelopmentandtestingmethodology.Themainargumentsforopensourceisthatmanymorepeoplelookatthecode,sothereisaformofpeerreviewandtheoddsofabugslip-pinginaremuchsmallerwithsomuchmoreinspection.2PROBLEMSOLUTIONSFORCHAPTER110.Thefilewillbeexecuted.11.Itisoftenessentialtohavesomeonewhocandothingsthatarenormallyfor-bidden.Forexample,auserstartsupajobthatgeneratesaninfiniteamountofoutput.Theuserthenlogsoutandgoesonathree-weekvacationtoLon-don.Soonerorlaterthediskwillfillup,andthesuperuserwillhavetomanu-allykilltheprocessandremovetheoutputfile.Manyothersuchexamplesexist.12.Anyfilecaneasilybenamedusingitsabsolutepath.Thusgettingridofworkingdirectoriesandrelativepathswouldonlybeaminorinconvenience.Theotherwayaroundisalsopossible,buttrickier.Inprincipleiftheworkingdirectoryis,say,/home/ast/projects/research/proj1onecouldrefertothepasswordfileas../../../../etc/passwd,butitisveryclumsy.Thiswouldnotbeapracticalwayofworking.13.Theprocesstableisneededtostorethestateofaprocessthatiscurrentlysuspended,eitherreadyorblocked.Itisnotneededinasingleprocesssys-tembecausethesingleprocessisneversuspended.14.Blockspecialfilesconsistofnumberedblocks,eachofwhichcanbereadorwrittenindependentlyofalltheotherones.Itispossibletoseektoanyblockandstartreadingorwriting.Thisisnotpossiblewithcharacterspecialfiles.15.Thereadworksnormally.User2’sdirectoryentrycontainsapointertothei-nodeofthefile,andthereferencecountinthei-nodewasincrementedwhenuser2linkedtoit.Sothereferencecountwillbenonzeroandthefileitselfwillnotberemovedwhenuser1removeshisdirectoryentryforit.Onlywhenalldirectoryentriesforafilehavebeenremovedwillitsi-nodeanddataactuallyvanish.16.No,theyarenotsoessential.Intheabsenceofpipes,program1couldwriteitsoutputtoafileandprogram2couldreadthefile.Whilethisislessefficientthanusingapipebetweenthem,andusesunnecessarydiskspace,inmostcircumstancesitwouldworkadequately.17.Thedisplaycommandandreponseforastereoorcameraissimilartotheshell.Itisagraphicalcommandinterfacetothedevice.18.Windowshasacallspawnthatcreatesanewprocessandstartsaspecificprograminit.Itiseffectivelyacombinationofforkandexec.19.Ifanordinaryusercouldsettherootdirectoryanywhereinthetree,hecouldcreateafileetc/passwdinhishomedirectory,andthenmakethattherootdirectory.Hecouldthenexecutesomecommand,suchassuorloginthatreadsthepasswordfile,andtrickthesystemintousinghispasswordfile,insteadoftherealone.PROBLEMSOLUTIONSFORCHAPTER1320.Thegetpid,getuid,getgid,andgetpgrp,callsjustextractawordfromthepro-cesstableandreturnit.Theywillexecuteveryquickly.Theyareallequallyfast.21.Thesystemcallscancollectivelyuse500millioninstructions/sec.Ifeachcalltakes1000instructions,upto500,000systemcalls/secarepossiblewhileconsumingonlyhalftheCPU.22.No,unlinkremovesanyfile,whetheritbeforaregularfileoraspecialfile.23.Whenauserprogramwritesonafile,thedatadoesnotreallygotothedisk.Itgoestothebuffercache.TheupdateprogramissuesSYNCcallsevery30secondstoforcethedirtyblocksinthecacheontothedisk,inordertolimitthepotentialdamagethatasystemcr

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

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

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

×
保存成功