操作系統(tǒng)習題_第1頁
操作系統(tǒng)習題_第2頁
操作系統(tǒng)習題_第3頁
操作系統(tǒng)習題_第4頁
操作系統(tǒng)習題_第5頁
已閱讀5頁,還剩60頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

Whatarethethreemainpurposesofanoperatingsystem?Answer:?Toprovideanenvironmentforacomputerusertoexecuteprogramsoncomputerhardwareinaconvenientandefficientmanner.?Toallocatetheseparateresourcesofthecomputerasneededtosolvetheproblemgiven.Theallocationprocessshouldbeasfairandefficientaspossible.Asacontrolprogramitservestwomajorfunctions:(1)supervision oftheexecutionofuserprogramstopreventerrorsandimproperuseofthecomputer,and(2)managementoftheoperationandcontrolofI/Odevices.Whatarethemaindifferencesbetweenoperatingsystemsformainframe computersandpersonalcomputers?Answer:Generally,operatingsystemsforbatchsystemshavesimplerrequirementsthanforpersonalcomputers.Batchsystemsdonothavetobeconcernedwithinteractingwithauserasmuchasapersonalcomputer.Asaresult,anoperating systemforaPCmustbeconcernedwithresponsetimeforaninteractiveuser.Batchsystemsdonothavesuchrequirements.Apurebatchsystemalsomayhavenottohandletimesharing,whereasanoperatingsystemmustswitchrapidlybetweendifferentjobs.Listthefourstepsthatarenecessarytorunaprogramonacompletelydedicatedmachine.Answer:Reservemachinetime.Manuallyloadprogramintomemory.Loadstartingaddressandbeginexecution.Monitorandcontrolexecutionofprogramfromconsole.Wehavestressedtheneedforanoperatingsystemtomakeefficientuseofthecomputinghardware.Whenisitappropriatefortheoperatingsystemtoforsakethisprincipleandtowaste resources?Whyissucasystemnotreallywasteful?Answer:Single-usersystemsshouldmaximizeuseofthesystemfortheuser.AGUImightwaste”CPUcycles,butitoptimizestheuserinteractionwiththesystem.'sWhatisthemaindifficultythataprogrammermustovercomeinwritinganoperatingsystemforareal-timeenvironment?Answer:Themaindifficultyiskeepingtheoperatingsystemwithinthe fixedtimeconstraintsofareal-timesystem.Ifthesystemdoesnotcompleteataskinacertaintimeframe,itmaycauseabreakdownoftheentiresystemitisrunning.Thereforewhenwritinganoperatingsystemforareal-timesystem,thewritermustbesurethathisscheduling schemesdon 'tallowresponsetimetoexceedthetimeconstraint.Considerthevariousdefinitionsofoperatingsystem.ConsiderwhethertheoperatingsystemshouldincludeapplicationssuchasWebbrowsersAndmailprograms.Argueboththatitshouldandthatitshouldnot,andsupportyouranswer.Answer: Point.Applicationssuchaswebbrowsersandemailtoolsareperforminganincreasinglyimportantroleinmoderndesktopcomputersystems.Tofulfillthisrole,theyshouldbeincorporatedaspartoftheoperatingsystem.Bydoingso,theycanprovidebetterperformanceandbetterintegrationwiththerestofthesystem.Inaddition,theseimportantapplicationscanhavethesamelook-and-feelastheoperatingsystemsoftware.Counterpoint.ThefundamentalroleoftheoperatingsystemistomanagesystemresourcessuchastheCPU,memory,I/Odevices,etc.Inaddition,it 'rolesistorunsoftwareapplicationssuchaswebbrowsersandemailapplications.Byincorporatingsuchapplicationsintotheoperatingsystem,weburdentheoperatingsystemwithadditionalfunctionality.Suchaburdenmayresultintheoperatingsystemperformingaless-thansatisfactoryjobatmanagingsystemresources.Inaddition,weincreasethesizeoftheoperatingsystemtherebyincreasingthelikelihoodofsystemcrashesandsecurityviolations.Howdoesthedistinctionbetweenkernelmodeandusermodefunctionasarudimentaryformofprotection(security)system?Answer:Thedistinctionbetweenkernelmodeandusermodeprovidesarudimentaryformofprotectioninthefollowingmanner.CertaininstructionscouldbeexecutedonlywhentheCPUisinkernelmode.Similarly,hardwaredevicescouldbeaccessedonlywhentheprogramisexecutinginkernelmode.ControloverwheninterruptscouldbeenabledordisabledisalsopossibleonlywhentheCPUisinkernelmode.Consequently,theCPUhasverylimitedcapabilitywhenexecutinginusermode,therebyenforcingprotectionofcriticalresources.Whichofthefollowinginstructionsshouldbeprivileged?Setvalueoftimer.Readtheclock.Clearmemory.Issueatrapinstruction.Turnoffinterrupts.Modifyentriesindevice-statustable.Switchfromusertokernelmode.AccessI/Odevice.Answer:Thefollowingoperationsneedtobeprivileged:Setvalueoftimer,clearmemory,turnoffinterrupts,modifyentriesindevice-statustable,accessI/Odevice.Therestcanbeperformedinusermode.Someearlycomputersprotectedtheoperatingsystembyplacingitinamemorypartitionthatcouldnotbemodifiedbyeithertheuserjobortheoperatingsystemitself.Describetwodifficultiesthatyouthinkcouldarisewithsuchascheme.Answer:Thedatarequiredbytheoperatingsystem(passwords,accesscontrols,accountinginformation,andsoon)wouldhavetobestoredinorpassedthroughunprotectedmemoryandthusbeaccessibletounauthorizedusers.SomeCPUprovideformorethantwomodesofoperation.Whataretwopossibleusesofthesemultiplemodes?Answer:Althoughmostsystemsonlydistinguishbetweenuserandkernelmodes,someCPUshavesupportedmultiplemodes.Multiplemodescouldbeusedtoprovideafiner-grainedsecuritypolicy.Forexample,ratherthandistinguishingbetweenjustuserandkernel-mode,youcoulddistinguishbetweendifferenttypesofusermode.Perhapsusersbelongingtothesamegroupcouldexecuteeachother c'desThemachinewouldgointoaspecifiedmodewhenoneoftheseuserswasrunningcode.Whenthemachinewasinthismode,amemberofthegroupcouldruncodebelongingtoanyoneelseinthegroup.Anotherpossibilitywouldbetoprovidedifferentdistinctionswithinkernelcode.Forexample,aspecificmodecouldallowUSBdevicedriverstorun.ThiswouldmeanthatUSBdevicescouldbeservicedwithouthavingtoswitchtokernelmode,therebyessentiallyallowingUSBdevicedriverstoruninaquasi-user/kernelmode.Timerscouldbeusedtocomputethecurrenttime.Provideashortdescriptionofhowthiscouldbeaccomplished.Answer:Aprogramcouldusethefollowingapproachtocomputethecurrenttimeusingtimerinterrupts.Theprogramcouldsetatimerforsometimeinthefutureandgotosleep.Whenitisawakenedbytheinterrupt,itcouldupdateitslocalstate,whichitisusingtokeeptrackofthenumberofinterruptsithasreceivedthusfar.Itcouldthenrepeatthisprocessofcontinuallysettingtimerinterruptsandupdatingitslocalstatewhentheinterruptsareactuallyraised.IstheInternetaLANoraWAN?Answer: TheInternetisaWANasthevariouscomputersarelocatedatgeographicallydifferentplacesandareconnectedbylong-distancenetworklinks.Whatisthepurposeofsystemcalls?Answer:Systemcallsallowuser-levelprocessestorequestservicesoftheoperatingsystem.Whatarethefivemajoractivitiesofanoperatingsysteminregardtoprocessmanagement?Answer:ThecreationanddeletionofbothuserandsystemprocessesThesuspensionandresumptionofprocessesTheprovisionofmechanismsforprocesssynchronizationTheprovisionofmechanismsforprocesscommunicationTheprovisionofmechanismsfordeadlockhandlingWhatarethethreemajoractivitiesofanoperatingsysteminregardtomemorymanagement?Answer:a.Keeptrackofwhichpartsofmemoryarecurrentlybeingusedandbywhom.Decidewhichprocessesaretobeloadedintomemorywhenmemoryspacebecomesavailable.Allocateanddeallocatememoryspaceasneeded.Whatarethethreemajoractivitiesofanoperatingsysteminregardtosecondary-storagemanagement?Answer:?Free-spacemanagement.Storageallocation.Diskscheduling.Whatisthepurposeofthecommandinterpreter?Whyisitusuallyseparatefromthekernel?Answer:Itreadscommandsfromtheuserorfromafileofcommandsandexecutesthem,usuallybyturningthemintooneormoresystemcalls.Itisusuallynotpartofthekernelsincethecommandinterpreterissubjecttochanges.Whatsystemcallshavetobeexecutedbyacommandinterpreterorshellinordertostartanewprocess?Answer:InUnixsystems,aforksystemcallfollowedbyanexecsystemcallneedtobeperformedtostartanewprocess.Theforkcallclonesthecurrentlyexecutingprocess,whiletheexeccalloverlaysanewprocessbasedonadifferentexecutableoverthecallingprocess.Whatisthepurposeofsystemprograms?Answer:Systemprogramscanbethoughtofasbundlesofusefulsystemcalls.Theyprovidebasicfunctionalitytouserssothatusersdonotneedtowritetheirownprogramstosolvecommonproblems.Whatisthemainadvantageofthelayeredapproachtosystemdesign?Whatarethedisadvantagesofusingthelayeredapproach?Answer:Asinallcasesofmodulardesign,designinganoperatingsysteminamodularwayhasseveraladvantages.Thesystemiseasiertodebugandmodifybecausechangesaffectonlylimitedsectionsofthesystemratherthantouchingallsectionsoftheoperatingsystem.Informationiskeptonlywhereitisneededandisaccessibleonlywithinadefinedandrestrictedarea,soanybugsaffectingthatdatamustbelimitedtoaspecificmoduleorlayer.Listfiveservicesprovidedbyanoperatingsystem.Explainhoweachprovidesconveniencetotheusers.Explainalsoinwhichcasesitwouldbeimpossibleforuser-levelprogramstoprovidetheseservices.Answer:Programexecution.Theoperatingsystemloadsthecontents(orsections)ofafileintomemoryandbeginsitsexecution.AuserlevelprogramcouldnotbetrustedtoproperlyallocateCPUtime.I/Ooperations.Disks,tapes,seriallines,andotherdevicesmustbecommunicatedwithataverylowlevel.Theuserneedonlyspecifythedeviceandtheoperationtoperformonit,whilethesystemconvertsthatrequestintodevice-orcontroller-specificcommands.User-levelprogramscannotbetrustedtoaccessonlydevicestheyshouldhaveaccesstoandtoaccessthemonlywhentheyareotherwiseunused.File-systemmanipulation.Therearemanydetailsinfilecreation,deletion,allocation,andnamingthatusersshouldnothavetoperform.Blocksofdiskspaceareusedbyfilesandmustbetracked.Deletingafilerequiresremovingthenamefileinformationandfreeingtheallocatedblocks.Protectionsmustalsobecheckedtoassureproperfileaccess.Userprogramscouldneitherensureadherencetoprotectionmethodsnorbetrustedtoallocateonlyfreeblocksanddeallocateblocksonfiledeletion.Communications.Messagepassingbetweensystemsrequiresmessagestobeturnedintopacketsofinformation,senttothenetworkcontroller,transmittedacrossacommunicationsmedium,andreassembledbythedestinationsystem.Packetorderinganddatacorrectionmusttakeplace.Again,userprogramsmightnotcoordinateaccesstothenetworkdevice,ortheymightreceivepacketsdestinedforotherprocesses.Errordetection.Errordetectionoccursatboththehardwareandsoftwarelevels.Atthehardwarelevel,alldatatransfersmustbeinspectedtoensurethatdatahavenotbeencorruptedintransit.Alldataonmediamustbecheckedtobesuretheyhavenotchangedsincetheywerewrittentothemedia.Atthesoftwarelevel,mediamustbecheckedfordataconsistency;forinstance,whetherthenumberofallocatedandunallocatedblocksofstoragematchthetotalnumberonthedevice.There,errorsarefrequentlyprocess-independent(forinstance,thecorruptionofdataonadisk),sotheremustbeaglobalprogram(theoperatingsystem)thathandlesalltypesoferrors.Also,byhavingerrorsprocessedbytheoperatingsystem,processesneednotcontaincodetocatchandcorrectalltheerrorspossibleonasystem.Whatisthepurposeofsystemcalls?Answer:Systemcallsallowuser-levelprocessestorequestservicesoftheoperatingsystem.Whatarethemainadvantagesofthemicrokernelapproachtosystemdesign?Answer:Benefitstypicallyincludethefollowing(a)addinganewservicedoesnotrequiremodifyingthekernel,(b)itismoresecureasmoreoperationsaredoneinusermodethaninkernelmode,and(c)asimplerkerneldesignandfunctionalitytypicallyresultsinamorereliableoperatingsystem.Whydosomesystemsstoretheoperatingsysteminfirmware,andothersondisk?Answer:Forcertaindevices,suchashandheldPDAsandcellulartelephones,adiskwithafilesystemmaybenotbeavailableforthedevice.Inthissituation,theoperatingsystemmustbestoredinfirmware.Howcouldasystembedesignedtoallowachoiceofoperatingsystemstobootfrom?Whatwouldthebootstrapprogramneedtodo?Answer:ConsiderasystemthatwouldliketorunbothWindowsXPandthreedifferentdistributionsofLinux(e.g.,RedHat,Debian,andMandrake).Eachoperatingsystemwillbestoredondisk.Duringsystemboot-up,aspecialprogram(whichwewillcallthebootmanager)willdeterminewhichoperatingsystemtobootinto.Thismeansthatratherinitiallybootingtoanoperatingsystem,thebootmanagerwillfirstrunduringsystemstartup.Itisthisbootmanagerthatisresponsiblefordeterminingwhichsystemtobootinto.Typicallybootmanagersmustbestoredatcertainlocationsoftheharddisktoberecognizedduringsystemstartup.Bootmanagersoftenprovidetheuserwithaselectionofsystemstobootinto;bootmanagersarealsotypicallydesignedtobootintoadefaultoperatingsystemifnochoiceisselectedbytheuser.PalmOSprovidesnomeansofconcurrentprocessing.Discussthreemajorcomplicationsthatconcurrentprocessingaddstoanoperatingsystem.Answer:Amethodoftimesharingmustbeimplementedtoalloweachofseveralprocessestohaveaccesstothesystem.ThismethodinvolvesthepreemptionofprocessesthatdonotvoluntarilygiveuptheCPU(byusingasystemcall,forinstance)andthekernelbeingreentrant(somorethanoneprocessmaybeexecutingkernelcodeconcurrently).Processesandsystemresourcesmusthaveprotectionsandmustbeprotectedfromeachother.Anygivenprocessmustbelimitedintheamountofmemoryitcanuseandtheoperationsitcanperformondeviceslikedisks.Caremustbetakeninthekerneltopreventdeadlocksbetweenprocesses,soprocessesaren 'twaitingforeachother 'sallocatedresources.TheSunUltraSPARCprocessorhasmultipleregistersets.Describetheactionsofacontextswitchifthenewcontextisalreadyloadedintooneoftheregistersets.Whatelsemusthappenifthenewcontextisinmemoryratherthaninaregistersetandalltheregistersetsareinuse?Answer:TheCPUcurrent-register-setpointerischangedtopointtothesetcontainingthenewcontext,whichtakesverylittletime.Ifthecontextisinmemory,oneofthecontextsinaregistersetmustbechosenandbe

movedtomemory,andthenewcontextmustbeloadedfrommemoryintotheset.Thisprocesstakesalittlemoretimethanonsystemswithonesetofregisters,dependingonhowareplacementvictimisselected.Whenaprocesscreatesanewprocessusingthefork()operation,whichofthefollowingstateissharedbetweentheparentprocessandthechildprocess?StackHeapSharedmemorysegmentsAnswer:Onlythesharedmemorysegmentsaresharedbetweentheparentprocessandthenewlyforkedchildprocess.Copiesofthestackandtheheaparemadeforthenewlycreatedprocess.3.4AgainconsideringtheRPCmechanism,considertheexactlyoncesem3.4AgainconsideringtheRPCmechanism,considertheexactlyoncesemDoesthealgorithmforimplementingthissemanticexecutecorrectlyevenifthe “ACK”messagebacktotheclientislostduetoanetworkproblem?Describethesequenceofmessagesandwhether"exactlyonce"isstillpreserved.seitharbtOcBeenoreprocedureAnswer:The “exactlyoncewillbeexecutedexactlyonceandonlyonce.Thegeneralalgorithmforensuringthiscombinesanacknowledgment(ACK)schemecombinedwithtimestamps(orsomeotherincrementalcounterthatallowstheseitharbtOcBeenoreprocedureThegeneralstrategyisfortheclienttosendtheRPCtotheserveralongwithatimestamp.Theclientwillalsostartatimeoutclock.Theclientwillthenwaitforoneoftwooccurrences:(1)itwillreceiveanACKfromtheserverindicatingthattheremoteprocedurewasperformed,or(2)itwilltimeout.Iftheclienttimesout,itassumestheserverwasunabletoperformtheremoteproceduresotheclientinvokestheRPCasecondtime,sendingalatertimestamp.TheclientmaynotreceivetheACKforoneoftworeasons:(1)theoriginalRPCwasneverreceivedbytheserver,or(2)theRPCwascorrectlyreceived —andperformed—bytheserverbuttheACKwaslost.Insituation(1),theuseofACKsallowstheserverultimatelytoreceiveandperformtheRPC.Insituation(2),theserverwillreceiveaduplicateRPCanditwillusethetimestamptoidentifyitasaduplicatesoasnottoperformtheRPCasecondtime.ItisimportanttonotethattheservermustsendasecondACKbacktotheclienttoinformtheclienttheRPChasbeenperformed.3.5Assumethatadistributedsystemissusceptibletoserverfailure.Whatsemanticsmechanismswouldberequiredtoguaranteethe “exactlyonceforexecutionofRPCs?semanticsAnswer:Theservershouldkeeptrackinstablestorage(suchasadisklog)informationregardingwhatRPCoperationswerereceived,whethertheyweresuccessfullyperformed,andtheresultsassociatedwiththeoperations.WhenaservercrashtakesplaceandaRPCmessage

isreceived,theservercancheckwhethertheRPChadbeenpreviouslysemancticsfortheperformedandthereforeguarantee “exactlyonceexecutionofRPCs.semancticsfortheProvidetwoprogrammingexamplesinwhichmultithreadingprovidesbetterperformancethanasingle-threadedsolution.Answer:(1)AWebserverthatserviceseachrequestinaseparatethread.2)(Aparallelizedapplicationsuchasmatrixmultiplicationwhere(differentpartsofthematrixmaybeworkedoninparallel.(3)An(interactiveGUIprogramsuchasadebuggerwhereathreadisused(tomonitoruserinput,anotherthreadrepresentstherunning(application,andathirdthreadmonitorsperformance.Whataretwodifferencesbetweenuser-levelthreadsandkernel-levelthreads?Underwhatcircumstancesisonetypebetterthantheother?Answer:(1)User-levelthreadsareunknownbythekernel,whereasthekernelisawareofkernelthreads.(2)OnsystemsusingeitherM:1orM:Nmapping,userthreadsarescheduledbythethreadlibraryandthekernelscheduleskernelthreads.(3)Kernelthreadsneednotbeassociatedwithaprocesswhereaseveryuserthreadbelongstoaprocess.Kernelthreadsaregenerallymoreexpensivetomaintainthanuserthreadsastheymustberepresentedwithakerneldatastructure.Describetheactionstakenbyakerneltocontextswitchbetweenkernellevelthreads.Answer:ContextswitchingbetweenkernelthreadstypicallyrequiressavingthevalueoftheCPUregistersfromthethreadbeingswitchedoutandrestoringtheCPUregistersofthenewthreadbeingscheduled.Whatresourcesareusedwhenathreadiscreated?Howdotheydifferfromthoseusedwhenaprocessiscreated?Answer:Becauseathreadissmallerthanaprocess,threadcreationtypicallyusesfewerresourcesthanprocesscreation.Creatingaprocessrequiresallocatingaprocesscontrolblock(PCB),aratherlargedatastructure.ThePCBincludesamemorymap,listofopenfiles,andenvironmentvariables.Allocatingandmanagingthememorymapistypicallythemosttime-consumingactivity.Creatingeitherauserorkernelthreadinvolvesallocatingasmalldatastructuretoholdaregisterset,stack,andpriority.Assumeanoperatingsystemmapsuser-levelthreadstothekernelusingthemany-to-manymodelandthemappingisdonethroughLWPs.Furthermore,thesystemallowsdeveloperstocreatereal-timethreads.Isitnecessarytobindareal-timethreadtoanLWP?Explain.Answer:Yes.Timingiscrucialtoreal-timeapplications.Ifathreadismarkedasreal-timebutisnotboundtoanLWP,thethreadmayhavetowaittobeattachedtoanLWPbeforerunning.Considerifareal-timethreadisrunning(isattachedtoanLWP)andthenproceedstoblock(i.e.mustperformI/O,hasbeenpreemptedbyahigher-priorityreal-timethread,iswaitingforamutualexclusionlock,etc.)Whilethereal-timethreadisblocked,theLWPitwasattachedtohasbeenassignedtoanotherthread.Whenthereal-timethreadhasbeenscheduledtorunagain,itmustfirstwaittobeattachedtoanLWP.BybindinganLWPtoarealtimethreadyouareensuringthethreadwillbeabletorunwithminimaldelayonceitisscheduled.APthreadprogramthatperformsthesummationfunctionwasprovidedinSection4.3.1.RewritethisprograminJava.Answer:PleaserefertothesupportingWebsiteforsourcecodesolution.ACPUschedulingalgorithmdeterminesanorderfortheexecutionofitsscheduledprocesses.Givennprocessestobescheduledononeprocessor,howmanypossibledifferentschedulesarethere?Giveaformulaintermsofn.x1).Answer:n!(nfactorial=n -1x-n2xin...xx1).Definethedifferencebetweenpreemptiveandnonpreemptivescheduling.Answer:Preemptiveschedulingallowsaprocesstobeinterruptedinthemidstofitsexecution,takingtheCPUawayandallocatingittoanotherprocess.NonpreemptiveschedulingensuresthataprocessrelinquishescontroloftheCPUonlywhenitfinisheswithitscurrentCPUburst.Supposethatthefollowingprocessesarriveforexecutionatthetimesindicated.Eachprocesswillrunthelistedamountoftime.Inansweringthequestions,usenonpreemptiveschedulingandbasealldecisionsontheinformationyouhaveatthetimethedecisionmustbemade.ProcessArrivalTimeBurstTimeP10.08P20.44P31.01WhatistheaverageturnaroundtimefortheseprocesseswiththeFCFSschedulingalgorithm?WhatistheaverageturnaroundtimefortheseprocesseswiththeSJFschedulingalgorithm?TheSJFalgorithmissupposedtoimproveperformance,butnoticethatwechosetorunprocessP1attime0becausewedidnotknowthattwoshorterprocesseswouldarrivesoon.ComputewhattheaverageturnaroundtimewillbeiftheCPUisleftidleforthefirst1unitandthenSJFschedulingisused.RememberthatprocessesP1andP2arewaitingduringthisidletime,sotheirwaitingtimemayincrease.Thisalgorithmcouldbeknownasfuture-knowledgescheduling.Answer:10.539.536.86Rememberthatturnaroundtimeisfinishingtimeminusarrivaltime,soyouhavetosubtractthearrivaltimestocomputetheturnaroundtimes.FCFSis11ifyouforgettosubtractarrivaltime.Whatadvantageisthereinhavingdifferenttime-quantumsizesondifferentlevelsofamultilevelqueueingsystem?Answer:Processesthatneedmorefrequentservicing,forinstance,interactiveprocessessuchaseditors,canbeinaqueuewithasmalltimequantum.Processeswithnoneedforfrequentservicingcanbeinaqueuewithalargerquantum,requiringfewercontextswitchestocompletetheprocessing,andthusmakingmoreefficientuseofthecomputer.ManyCPU-schedulingalgorithmsareparameterized.Forexample,theRRalgorithmrequiresaparametertoindicatethetimeslice.Multilevelfeedbackqueuesrequireparameterstodefinethenumberofqueues,theschedulingalgorithmsforeachqueue,thecriteriausedtomoveprocessesbetweenqueues,andsoon.Thesealgorithmsarethusreallysetsofalgorithms(forexample,thesetofRRalgorithmsforalltimeslices,andsoon).Onesetofalgorithmsmayincludeanother(forexample,theFCFSalgorithmistheRRalgorithmwithaninfinitetimequantum).What(ifany)relationholdsbetweenthefollowingpairsofsetsofalgorithms?PriorityandSJFMultilevelfeedbackqueuesandFCFSPriorityandFCFSRRandSJFAnswer:Theshortestjobhasthehighestpriority.ThelowestlevelofMLFQisFCFS.FCFSgivesthehighestprioritytothejobhavingbeeninexistencethelongest.None.Supposethataschedulingalgorithm(atthelevelofshort-termCPUscheduling)favorsthoseprocessesthathaveusedtheleastprocessortimeintherecentpast.WhywillthisalgorithmfavorI/O-boundprogramsandyetnotpermanentlystarveCPU-boundprograms?Answer:ItwillfavortheI/O-boundprogramsbecauseoftherelativelyshortCPUburstrequestbythem;however,theCPU-boundprogramswillnotstarvebecausetheI/O-boundprogramswillrelinquishtheCPUrelativelyoftentodotheirI/O.DistinguishbetweenPCSandSCSscheduling.Answer:PCSschedulingisdonelocaltotheprocess.ItishowthethreadlibraryschedulesthreadsontoavailableLWPs.SCSschedulingisthesituationwheretheoperatingsystemscheduleskernelthreads.Onsystemsusingeithermany-to-oneormany-to-many,thetwoschedulingmodelsarefundamentallydifferent.Onsystemsusingone-to-one,PCSandSCSarethesame.Assumeanoperatingsystemmapsuser-levelthreadstothekernelusingthemany-to-manymodelwherethemappingisdonethroughtheuseofLWPs.Furthermore,thesystemallowsprogramdeveloperstocreatereal-timethreads.Isitnecessarytobindareal-timethreadtoanLWP?Answer:Yes,otherwiseauserthreadmayhavetocompeteforanavailableLWPpriortobeingactuallyscheduled.BybindingtheuserthreadtoanLWP,thereisnolatencywhilewaitingforanavailableLWP;thereal-timeuserthreadcanbescheduledimmediately.InSection6.4wementionedthatdisablinginterruptsfrequentlycouldaffectthesystem 'sclock.Explainwhyitcouldandhowsucheffectscouldbeminimized.Answer:Thesystemclockisupdatedateveryclockinterrupt.Ifinterruptsweredisabled——particularlyforalongperiodoftime ——itispossiblethesystemclockcouldeasilylosethecorrecttime.Thesystemclockisalsousedforschedulingpurposes.Forexample,thetimequantumforaprocessisexpressedasanumberofclockticks.Ateveryclockinterrupt,theschedulerdeterminesifthetimequantumforthecurrentlyrunningprocesshasexpired.Ifclockinterruptsweredisabled,theschedulercouldnotaccuratelyassigntimequantums.Thiseffectcanbeminimizedbydisablingclockinterruptsforonlyveryshortperiods.TheCigarette-SmokersProblem.Considerasystemwiththreesmokerprocessesandoneagentprocess.Eachsmokercontinuouslyrollsacigaretteandthensmokesit.Buttorollandsmokeacigarette,thesmokerneedsthreeingredients:tobacco,paper,andmatches.Oneofthesmokerprocesseshaspaper,anotherhas

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論