操作系统精髓与设计原理第五版 课后题答案.docx
《操作系统精髓与设计原理第五版 课后题答案.docx》由会员分享,可在线阅读,更多相关《操作系统精髓与设计原理第五版 课后题答案.docx(17页珍藏版)》请在冰豆网上搜索。
![操作系统精髓与设计原理第五版 课后题答案.docx](https://file1.bdocx.com/fileroot1/2023-2/5/4626aa04-c90a-4afa-9909-60bfd794286a/4626aa04-c90a-4afa-9909-60bfd794286a1.gif)
操作系统精髓与设计原理第五版课后题答案
Chapter2
OperatingSystemOverview
ReviewQuestions
2.1Convenience:
Anoperatingsystemmakesacomputermoreconvenienttouse.Efficiency:
Anoperatingsystemallowsthecomputersystemresourcestobeusedinanefficientmanner.Abilitytoevolve:
Anoperatingsystemshouldbeconstructedinsuchawayastopermittheeffectivedevelopment,testing,andintroductionofnewsystemfunctionswithoutinterferingwithservice.
2.5Theexecutioncontext,orprocessstate,istheinternaldatabywhichtheoperatingsystemisabletosuperviseandcontroltheprocess.Thisinternalinformationisseparatedfromtheprocess,becausetheoperatingsystemhasinformationnotpermittedtotheprocess.Thecontextincludesalloftheinformationthattheoperatingsystemneedstomanagetheprocessandthattheprocessorneedstoexecutetheprocessproperly.Thecontextincludesthecontentsofthevariousprocessorregisters,suchastheprogramcounteranddataregisters.Italsoincludesinformationofusetotheoperatingsystem,suchasthepriorityoftheprocessandwhethertheprocessiswaitingforthecompletionofaparticularI/Oevent.
Problems
2.1Theanswersarethesamefor(a)and(b).Assumethatalthoughprocessoroperationscannotoverlap,I/Ooperationscan.
1Job:
TAT=NTProcessorutilization=50%
2Jobs:
TAT=NTProcessorutilization=100%
4Jobs:
TAT=(2N–1)NTProcessorutilization=100%
2.4Asystemcallisusedbyanapplicationprogramtoinvokeafunctionprovidedbytheoperatingsystem.Typically,thesystemcallresultsintransfertoasystemprogramthatrunsinkernelmode.
Chapter3
ProcessDescriptionandControl
ReviewQuestions
3.5Swappinginvolvesmovingpartorallofaprocessfrommainmemorytodisk.WhennoneoftheprocessesinmainmemoryisintheReadystate,theoperatingsystemswapsoneoftheblockedprocessesoutontodiskintoasuspendqueue,sothatanotherprocessmaybebroughtintomainmemorytoexecute.
3.10Theusermodehasrestrictionsontheinstructionsthatcanbeexecutedandthememoryareasthatcanbeaccessed.Thisistoprotecttheoperatingsystemfromdamageoralteration.Inkernelmode,theoperatingsystemdoesnothavetheserestrictions,sothatitcanperformitstasks.
Problems
3.1•Creationanddeletionofbothuserandsystemprocesses.Theprocessesinthesystemcanexecuteconcurrentlyforinformationsharing,computationspeedup,modularity,andconvenience.Concurrentexecutionrequiresamechanismforprocesscreationanddeletion.Therequiredresourcesaregiventotheprocesswhenitiscreated,orallocatedtoitwhileitisrunning.Whentheprocessterminates,theOSneedstoreclaimanyreusableresources.
•Suspensionandresumptionofprocesses.Inprocessscheduling,theOSneedstochangetheprocess'sstatetowaitingorreadystatewhenitiswaitingforsomeresources.Whentherequiredresourcesareavailable,OSneedstochangeitsstatetorunningstatetoresumeitsexecution.
•Provisionofmechanismforprocesssynchronization.Cooperatingprocessesmaysharedata.Concurrentaccesstoshareddatamayresultindatainconsistency.OShastoprovidemechanismsforprocessessynchronizationtoensuretheorderlyexecutionofcooperatingprocesses,sothatdataconsistencyismaintained.
•Provisionofmechanismforprocesscommunication.TheprocessesexecutingundertheOSmaybeeitherindependentprocessesorcooperatingprocesses.Cooperatingprocessesmusthavethemeanstocommunicatewitheachother.
•Provisionofmechanismsfordeadlockhandling.Inamultiprogrammingenvironment,severalprocessesmaycompeteforafinitenumberofresources.Ifadeadlockoccurs,allwaitingprocesseswillneverchangetheirwaitingstatetorunningstateagain,resourcesarewastedandjobswillneverbecompleted.
3.3Figure9.3showstheresultforasingleblockedqueue.Thefigurereadilygeneralizestomultipleblockedqueues.
Chapter4
ProcessDescriptionandControl
ReviewQuestions
4.2Lessstateinformationisinvolved.
4.5Addressspace,fileresources,executionprivilegesareexamples.
4.61.Threadswitchingdoesnotrequirekernelmodeprivilegesbecauseallofthethreadmanagementdatastructuresarewithintheuseraddressspaceofasingleprocess.Therefore,theprocessdoesnotswitchtothekernelmodetodothreadmanagement.Thissavestheoverheadoftwomodeswitches(usertokernel;kernelbacktouser).2.Schedulingcanbeapplicationspecific.Oneapplicationmaybenefitmostfromasimpleround-robinschedulingalgorithm,whileanothermightbenefitfromapriority-basedschedulingalgorithm.TheschedulingalgorithmcanbetailoredtotheapplicationwithoutdisturbingtheunderlyingOSscheduler.3.ULTscanrunonanyoperatingsystem.NochangesarerequiredtotheunderlyingkerneltosupportULTs.Thethreadslibraryisasetofapplication-levelutilitiessharedbyallapplications.
4.71.Inatypicaloperatingsystem,manysystemcallsareblocking.Thus,whenaULTexecutesasystemcall,notonlyisthatthreadblocked,butalsoallofthethreadswithintheprocessareblocked.2.InapureULTstrategy,amultithreadedapplicationcannottakeadvantageofmultiprocessing.Akernelassignsoneprocesstoonlyoneprocessoratatime.Therefore,onlyasinglethreadwithinaprocesscanexecuteatatime.
Problems
4.2Because,withULTs,thethreadstructureofaprocessisnotvisibletotheoperatingsystem,whichonlyschedulesonthebasisofprocesses.
Chapter5
Concurrency:
MutualExclusionandSynchronization
ReviewQuestions
5.1Communicationamongprocesses,sharingofandcompetingforresources,synchronizationoftheactivitiesofmultipleprocesses,andallocationofprocessortimetoprocesses.
5.9Abinarysemaphoremayonlytakeonthevalues0and1.Ageneralsemaphoremaytakeonanyintegervalue.
Problems
5.2ABCDE;ABDCE;ABDEC;ADBCE;ADBEC;ADEBC;
DEABC;DAEBC;DABEC;DABCE
5.5Considerthecaseinwhichturnequals0andP
(1)setsblocked[1]totrueandthenfindsblocked[0]settofalse.P(0)willthensetblocked[0]totrue,findturn=0,andenteritscriticalsection.P
(1)willthenassign1toturnandwillalsoenteritscriticalsection.
Chapter6
Concurrency:
DeadlockandStarvation
ReviewQuestions
6.2Mutualexclusion.Onlyoneprocessmayusearesourceatatime.Holdandwait.Aprocessmayholdallocatedresourceswhileawaitingassignmentofothers.Nopreemption.Noresourcecanbeforciblyremovedfromaprocessholdingit.
6.3Theabovethreeconditions,plus:
Circularwait.Aclosedchainofprocessesexists,suchthateachprocessholdsatleastoneresourceneededbythenextprocessinthechain.
Problems
6.4a.0000
0750
6622
2002
0320
b.tod.Runningthebanker'salgorithm,weseeprocessescanfinishintheorderp1,p4,p5,p2,p3.
e.Changeavailableto(2,0,0,0)andp3'srowof"stillneeds"to(6,5,2,2).Nowp1,p4,p5canfinish,butwithavailablenow(4,6,9,8)neitherp2norp3's"stillneeds"canbesatisfied.Soitisnotsafetograntp3'srequest.
6.51.W=(2100)
2.MarkP3;W=(2100)+(0120)=(2220)
3.MarkP2;W=(2220)+(2001)=(4221)
4.MarkP1;nodeadlockdetected
Chapter7
MemoryManagement
ReviewQuestions
7.1Relocation,protection,sharing,logicalorganization,physicalorganization.
7.7Alogicaladdressisareferencetoamemorylocationindependentofthecurrentassignmentofdatatomemory;atranslationmustbemadetoaphysicaladdressbeforethememoryaccesscanbeachieved.Arelativeaddressisaparticularexampleoflogicaladdress,inwhichtheaddressisexpressedasalocationrelativetosomeknownpoint,usuallythebeginningoftheprogram.Aphysicaladdress,orabsoluteaddress,isanactuallocationinmainmemory.
Problems
7.6a.The40Mblockfitsintothesecondhole,withastartingaddressof80M.The20Mblockfitsintothefirsthole,withastartingaddressof20M.The10Mblockisplacedatlocation120M.
b.Thethreestartingaddressesare230M,20M,and160M,forthe40M,20M,and10Mblocks,respectively.
c.Thethreestartingaddressesare80M,120M,and160M,forthe40M,20M,and10Mblocks,respectively.
7.12a.Thenumberofbytesinthelogicaladdressspaceis(216pages)´(210bytes/page)=226bytes.Therefore,26bitsarerequiredforthelogicaladdress.
b.Aframeisthesamesizeasapage,210bytes.
c.Thenumberofframesinmainmemoryis(232bytesofmainmemory)/(210bytes/frame)=222frames.So22bitsisneededtospecifytheframe.
d.Thereisoneentryforeachpageinthelogicaladdressspace.Thereforethereare216entries.
e.Inadditiontothevalid/invalidbit,22bitsareneededtospecifytheframelocationinmainmemory,foratotalof23bits.
d.Thethreestartingaddressesare80M,230M,and360M,forthe40M,20M,and10Mblocks,respectively.
Chapter8
VirtualMemory
ReviewQuestions
8.1Simplepaging:
allthepagesofaprocessmustbeinmainmemoryforprocesstorun,unlessoverlaysareused.Virtualmemorypaging:
notallpagesofaprocessneedbeinmainmemoryframesfortheprocesstorun.;pagesmaybereadinasneeded
8.2Aphenomenoninvirtualmemoryschemes,inwhichtheprocessorspendsmostofitstimeswappingpiecesratherthanexecutinginstructions.
Problems
8.1a.Splitbinaryaddressintovirtualpagenumberandoffset;useVPNasindexintopagetable;extractpageframenumber;concatenateoffsettogetphysicalmemoryaddress
b.(i)1052=1024+28mapstoVPN1inPFN7,(7⨯1024+28=7196)
(ii)2221=2⨯1024+173mapstoVPN2,pagefault
(iii)5499=5⨯1024+379mapstoVPN5inPFN0