操作系统复习题

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

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

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

资源描述

ModernOperatingSystems-ByLunaIfyouhaveanyquestionsaboutthisdocument,pleasesendEmailtogao.xue.qi@qq.comCHAP1INTRODUCTION5.OnereasonGUIswereinitiallyslowtobeadoptedwasthecostofthehardwareneededtosupportthem.HowmuchvideoRAMisneededtosupporta25line×80rowcharactermonochrometextscreen?Howmuchfora1024×768pixel24-bitcolorbitmap?WhatwasthecostofthisRAMat1980prices(5$/KB)?Howmuchisitnow?Answer:A25×80charactermonochrometextscreenrequiresa2000-bytebuffer.The1024×768pixel24-bitcolorbitmaprequires2,359,296bytes.In1980thesetwooptionswouldhavecost$10and$11,520,respectively.Forcurrentprices,checkonhowmuchRAMcurrentlycosts,probablylessthan$1/MB.8.ConsiderasystemthathastwoCPUsandeachCPUhastwothreads(hyperthreading).Supposethreeprograms,P0,P1,andP2,arestartedwithruntimesof5,10and20mses,respectively.Howlongwillittaketocompletetheexecutionoftheseprograms?Assumethatallthreeprogramsare100%CPUbound,donotblockduringexecution,anddonotchangeCPUsonceassigned.Answer:Itmaytake20,25or30msestocompletetheexecutionoftheseprogramsdependingonhowtheoperatingsystemschedulesthem.IfP0andP1arescheduledonthesameCPUandP2isscheduledontheotherCPU,itwilltake20mses.IfP0andP2arescheduledonthesameCPUandP1isscheduledontheotherCPU,itwilltake25msec.IfP1andP2arescheduledonthesameCPUandP0isscheduledontheotherCPU,itwilltake30msec.IfallthreeareonthesameCPU,itwilltake35msec.9.Acomputerhasapipelinewithfourstages.Eachstagetakesthesametimetodoitswork,namely,1nsec.Howmanyinstructionspersecondcanthismachineexecute?Answer:Everynanosecondoneinstructionemergesfromthepipeline.Thismeansthemachineisexecuting1billioninstructionspersecond.Itdoesnotmatteratallhowmanystagesthepipelinehas.A10-stagepipelinewith1nsecperstagewouldalsoexecute1billioninstructionspersecond.Allthatmattersishowoftenafinishedinstructionpopsouttheendofthepipeline.10.Consideracomputersystemthathascachememory,mainmemory(RAM)anddisk,andtheoperatingsystemusesvirtualmemory.Ittakes2nsectoaccessawordfromthecache,10nsectoaccessawordfromtheRAM,and10mstoaccessawordfromthedisk.Ifthecachehitrateis95%andmainmemoryhitrate(afteracachemiss)is99%,whatistheaveragetimetoaccessaword?Answer:Averageaccesstime=0.95×2nsec(wordiscache)+0.05×0.99×10nsec(wordisinRAM,butnotincache)+0.05×0.01×10,000,000nsec(wordondiskonly)=5002.395nsec=5.002395μsec14.Whatisthekeydifferencebetweenatrapandaninterrupt?Answer:Atrapiscausedbytheprogramandissynchronouswithit.Iftheprogramisrunagainandagain,thetrapwillalwaysoccuratexactlythesamepositionintheinstructionstream.Aninterruptiscausedbyanexternaleventanditstimingisnotreproducible.20.Afilewhosefiledescriptorisfdcontainsthefollowingsequenceofbytes:3,1,4,1,5,9,2,6,5,3,5.Thefollowingsystemcallsaremade:lseek(fd,3,SEEK_SET);Read(fd,&buffer,4);Wherethelseekcallmakesaseektobyte3ofthefile.Whatdoesbuffercontainafterthereadhascompleted?Answer:Itcontainsthebytes:1,5,9,2.22.Whatistheessentialdifferencebetweenablockspecialfileandacharacterspecialfile?Answer:Blockspecialfilesconsistofnumberedblocks,eachofwhichcanbereadorwrittenindependentlyofalltheotherones.Itispossibletoseektoanyblockandstartreadingorwriting.Thisisnotpossiblewithcharacterspecialfiles.25.Toaprogrammer,asystemcalllookslikeanyothercalltoalibraryprocedure.Isitimportantthataprogrammerknowwhichlibraryproceduresresultinsystemcalls?Underwhatcircumstancesandwhy?Answer:Asfarasprogramlogicisconcerneditdoesnotmatterwhetheracalltoalibraryprocedureresultsinasystemcall.Butifperformanceisanissue,ifataskcanbeaccomplishedwithoutasystemcalltheprogramwillrunfaster.Everysystemcallinvolvesoverheadtimeinswitchingfromtheusercontexttothekernelcontext.Furthermore,onamultiusersystemtheoperatingsystemmayscheduleanotherprocesstorunwhenasystemcallcompletes,furtherslowingtheprogressinrealtimeofacallingprocess.28.Explainhowseparationofpolicyandmechanismaidsinbuildingmicrokernel-basedoperatingsystems.Answer:SeparationofpolicyandmechanismallowsOSdesignerstoimplementasmallnumberofbasicprimitivesinthekernel.Theseprimitivesaresimplified,becausetheyarenotdependentofanyspecificpolicy.Theycanthenbeusedtoimplementmorecomplexmechanismsandpoliciesattheuserlevel.29.Herearesomequestionsforpracticingunitconversions:(a)Howlongisamicroyearinseconds?(b)Micrometersareoftencalledmicrons.Howlongisagigamicron?(c)Howmanybytesarethereina1-TBmemory?(d)Themassoftheearthis6000yottagrams.Whatisthatinkilograms?Answer:Theconversionsarestraightforward:(a)Amicroyearis10−6×365×24×3600=31.536sec.(b)1000metersor1km.(c)Thereare240bytes,whichis1,099,511,627,776bytes.(d)Itis6×1024kg.CHAP2PROCESSESANDTHREADS2.Supposethatyouweretodesignanadvancedcomputerarchitecturethatdidprocessswitchinginhardware,insteadofhavinginterrupts.WhatinformationwouldtheCPUneed?Describehowthehardwareprocessswitchingmightwork.Answer:Youcouldhavearegistercontainingapointertothecurrentprocesstableentry.WhenI/Ocompleted,theCPUwouldstorethecurrentmachinestateinthecurrentprocesstableentry.Thenitwouldgototheinterruptvectorfortheinterruptingdeviceandfetchapointertoanotherprocesstableentry(theserviceprocedure).Thisprocesswouldthenbestartedup.3.Onal

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

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

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

×
保存成功