操作系统英文版课后习题答案整理word文档良心出品Word格式.docx
《操作系统英文版课后习题答案整理word文档良心出品Word格式.docx》由会员分享,可在线阅读,更多相关《操作系统英文版课后习题答案整理word文档良心出品Word格式.docx(16页珍藏版)》请在冰豆网上搜索。
gramitservestwomajorfunctions:
(1)supervisionoftheexecutionofuserprogramstopreventerrorsandimproperuseofthecomputer,and
(2)managementofthe«
peratit)JIandcontrolof[/Odevices.
1.2Listthefourstepsthatarenecessarytorunaprogramonacompletelydedicatedmachine.Preprocessing>
Processing>
Linking>
Executing.
Answer
乩Reservemachinetime*
b.Manuallyloadprogramintomemory.
c.Loadstartingaddressandbeginexecution.
d.Monitorandcontrolexecutionofprogramfnimct>
nsoie.
1.6Definetheessentialpropertiesofthefollowingtypesofoperatingsystems:
a.Batch
b.Interactive
c.Timesharing
d.Realtime
e.Network
f.Distributed
a”
b.
c.
Batch.Jobswithsimilarneedsarebatchedtogetherandrunthroughthecomputerasagrcupbyanoperatororautomaticjobst^quencer.[咆jrformHrk:
电isincreasedbyatteiTiptingtokeepCPUandI/Odevicesbusv試alltimesthroughoff-line
operation,Kptx?
ling,andmultiprogramming*Batchisgoodforexecutinglargejobsthatnetxlinteraction;
itcanbesiubmiltedandpickeduplater
Interactive.ThkinJofmanyshorttransactiorifdwheretheresultsof
thenexttransactionmaybeunpredictable.Responserirneneedstobeshort(seconds]sincetheusersubmilsandw^iihFortheresult.
Timesharing.Thissystemsu&
es匚nschedulingandmLiltiprt)grammingtoprtividt*economicalinteractiveofasystem.TheCP匚占w让chemrapidlyfn>
nnoneusertoanotherInsteadofhavingajobdefinedbyspooledcardimages^eachprogramre^ds
itsnextcontrolcardfromtheterminal,andoutputisnormallyprintedimmediatelytothescreen.
d.
Realtime.Oftenusvdinadedicatedapplication,tliissystemreadsinformationframsensorsandmustrespondwithinafixedamountoftimetoensurecorrectperformance-
Network.
Distributed.Thissystemdistributescomputationarntmgse¥
t?
ralphysicalprtxzesKors,Theprt>
cesst>
rsdonotsharememoryoracltKk.Instead,eachprixessorhasitst>
wnkxzalmemory.Theycommunicatewitheachotherthroughvariouscommunicatitmlines,suchasahigh-speedbusortelephoneline.
Wehavestressedtheneedforanoperatingsystemtomakeefficientuseofthecomputing
1.7
hardware.Whenisitappropriatefortheoperatingsystemtoforsakethisprincipleandtowaste"
resources?
Whyissuchasystemnotreallywasteful?
AnswerSingle*usersystemsshtiuIdmaximizeuseofthesystennfortheuser.AGUImight“waste"
CPUcy<
les,butitoptimizestheuser'
sinteractionwiththesystem.
2.2Howdoesthedistinctionbetweenmonitormodeandusermodefunctionasarudimentaryformofprotection(security)system?
亠■■
Answer;
Byestablishingasetofprivilegedinstructionsthatcanbeexecutedonlywheninthemt>
niu)rmode,theoperatingsystemisassuredofct^ntrollingtheentiresystematalltimes.
2.3Whatarethedifferencesbetweenatrapandaninterrupt?
Whatistheuseofeachfunction?
AnswerAninterruptisahardware-generatedchange-of-flowwithinthesystem.Aninterrupthandlerissummonedtodealwiththec<
iuseoFtheinterrupt;
controlisthenre*
turnedtotheinterruptedcontextandinstruction.Atrapisasoftware-generatedinterrup匕AninterruptcanbvusvdtosignalthecoiTipJctk*nofan[/Otoobviatetheneedfnrdu\icypoiling.Atrapcanbeusedtocalloperatingsystemroutinesortocatcharithmeticerrors.
2.5Whichofthefollowinginstructionsshouldbeprivileged?
a.Setvalueoftimer.
b.Readtheclock.
c.Clearmemory.
d.Turnoffinterrupts.
e.Switchfromusertomonitormode.
Thefollowinginstructionsshouldbeprivileged:
a.Setvalueoftimer.
b.Clearmemory.
c.Turnoffinterrupta
cLSwitchfromusertomonitormode.
2.8Protectingtheoperatingsystemiscrucialtoensuringthatthecomputersystemoperatescorrectly.Provisionofthisprotectionisthereasonbehinddual-modeoperation,memoryprotection,andthetimer.Toallowmaximumflexibility,however,wewouldalsoliketoplaceminimalconstraintsontheuser.
Thefollowingisalistofoperationsthat
ofinstructionsthatmustbeprotected?
a.Changetousermode.
b.Changetomonitormode.
c.Readfrommonitormemory.
d.Writeintomonitormemory.
e.Fetchaninstructionfrommonitormemory.
f.Turnontimerinterrupt.
g.Turnofftimerinterrupt.
AnswenTheminimalsetofinstructionsthatmustbeprotectedare:
Readfrommonitormemory*
Writeintomonitormemorv.
*
Turnofftimerinterrupt.
3.6Listfiveservicesprovidedbyanoperatingsystem.Explainhoweachprovidesconveniencetotheusers.Explainalsoinwhichcasesitwouldbeimpossibleforuser-level
programstoprovidetheseservices.
Programexecution.Theoperatingsystemloadsthecontents(orsections)ofafileintomemoryandbeginsitsexecution.Auser-levelpm呂ramcouldnotbetrustedtoproperlyallocateCPUtime.
I/O'
operations.Disks,tapes,seriallines^andotherdevicesmustbecommunicatedwithata\erylowlevel.Theuserneedonlyspecifythedeviceandtheoperationtoperformonit,whilethesystemconvertsthatrequestintodevice-orcontroller-specificcommands.User-levelprogramscannotbetrustedtoonlyaccessdevicestheyshouldhaveaccesstonndtoonlyaccessthemwhentheyartotherwiseunused.
File-systemmanipulation.Therearvmanydetailsinfilecreation,deletion,alkKation,andnamingthatusersshouldnothavetoperform.Blocksofdiskspact?
areusedbyfilesandmustbetracked.Deletingafilerequiresremovingthenamefileinformationandfreeingthe说[locatedbk>
cks.[Protectionsmustalsobecheckedtoassureprtiperfileaccess.Userprt^gramscouldneitherensureadherencetctprotectionmethexJsnorbetrustedtoallocateonlyfreeblocksanddeallocateblocksonfiledeletion.
Communications.Messagepassingbetweensystemsrequiresmessagesbeturnedintopacketsofinformation,senttothenetworkcontnUlei;
transmittedacrossacommunicationsmedium,andreassembledbythedestinationsystem.Packetorderinganddatacorrectionmusttakeplace.Again,userprogramsmightnotcoordinateaccesstothenetworkdevice,ortheymightreevi^Tpacketsdestinedforotherprocesses.
•Errordetection.Errordetectionoccursatboththehardwareandsofirwarelevels.Atthehardwarele\-el,alldatatransfersmustbeinspectedtoensurethatdatahavenotbeenc(>
rruptedintransitAUdataonmediamustbicheckedtobesuretheyhavenotchangedsincetheywerewrittentothemedia.Atthesoftwarelevel,mediamustbecheckedfordataconsistency;
forinstance,dothenumberofallt>
catedandunallocatedblocksofstoragematchthetotalnumberonthedevice.There,errorsarefrequentlyprexzess-independent(forinstance,thecorruptionofdataonadisk),sotheremustbeaglobalprogram(ttiEoperatingsystem)thathandlesalltype吕oferrors.Also,byhavingerrorsprocessedbytheoperatingsystem,processesneednotcontaincodetocatchandcorrectallthEerrorspossibleonasystEm.
3.7Whatisthepurposeofsystemcalls?
AnswerSystemualls(j1U>
wuser-lewlliirequesticesuftl咤uperdtingsv;
»
-
tem.
3.10Whatisthepurposeofsystemprograms?
jVnswcr:
Evstemprogramscanbethoughtofbundlcz^ufusefulsystctuoils.Tbev
providebasicfuncticrahtytousersandsousersdenotneedtowritetheirownprogramstosol、忙commonproblems.
4.1MS-DOSprovidednomeansofconcurrentprocessing.Discussthreemajorcomplicationsthatconcurrentprocessingaddstoanoperatingsystem.
Amethodoftimesharingmustbeimplementedtoalloweachofseveralprocessestohaveaccesstothesysten'
i.ThismethodinxoJvcsthepromptionofprocessesthatdonotvoluntarilygiA-euptheCPU(byusingasystemcal],forinstance)<
indthekernelbeingreentrant(somorethanoneprtxzessmaybeexecutingkernelcodeconcurrently).
Processesandsystemresourcesmusthaveprotectionsandmustbeprciteck?
dfrtiTneachotherAnygivenprocessmustbelimitedintheamountofmemoryitcanuseandtheoperationsitcanperformondeviceslikedisks.
Thecorrectproducer—consumeralgorithminSection4.4allowsonlyn-1bufferstobe
Caremustbetakeninthekerneltopre\entdeadkxzksbetweenprocesse鬲soprcicessesaren'
twaitingforeachother'
sallcxatedrest>
urces.
4.6
fullatanyonetime.Modifythealgorithmtoallowallbufferstobeutilizedfully.
AnswerNoanswer.
5.1Providetwoprogrammingexamplesofmultithreadinggivingimproveperformaneeover
asingle-threadedsolution.
Answer
(1)Aserverthatserviceseachrequestinaseparatethread.
(2)Aparal*lelizedapplicationsuchasmatrixmultiplicationwheredifferentpartsofthematrixmaybeworkedoninparallel.(3)AninteractiveGUIprogramsuchasadibuggerwhereathreadisusedtomonitoruserinput,anotherthreadrepresentstherunningflppHcation,andathirdthreadmonitorsperformance.
5.3Whataretwodifferencesbetweenuser-levelthreadsandkernel-levelthreads?
Under
whatcircumstancesisonetypebetterthantheother?
r■
AnswerContextswitchingbetweenusertlireadsisquitesimilartGswitchingbetweenkernelthreads,althoughitis