/
The Abstraction The Process In this chapter we discuss one of the most fundamental abstr The Abstraction The Process In this chapter we discuss one of the most fundamental abstr

The Abstraction The Process In this chapter we discuss one of the most fundamental abstr - PDF document

karlyn-bohler
karlyn-bohler . @karlyn-bohler
Follow
627 views
Uploaded On 2015-01-15

The Abstraction The Process In this chapter we discuss one of the most fundamental abstr - PPT Presentation

The de64257nition of a process infor mally is quite simple it is a running program V65BH70 The program itself is a lifeless thing it just sits there on the disk a bu nch of instructions and maybe some static data waiting to spring into action It is ID: 31770

The de64257nition

Share:

Link:

Embed:

Download Presentation from below link

Download Pdf The PPT/PDF document "The Abstraction The Process In this chap..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

4TheAbstraction:TheProcessInthischapter,wediscussoneofthemostfundamentalabstractionsthattheOSprovidestousers:theprocess.Thedenitionofaprocess,infor-mally,isquitesimple:itisarunningprogram[V+65,BH70].Theprogramitselfisalifelessthing:itjustsitsthereonthedisk,abunchofinstructions(andmaybesomestaticdata),waitingtospringintoaction.Itistheoper-atingsystemthattakesthesebytesandgetsthemrunning,transformingtheprogramintosomethinguseful.Itturnsoutthatoneoftenwantstorunmorethanoneprogramatonce;forexample,consideryourdesktoporlaptopwhereyoumightliketorunawebbrowser,mailprogram,agame,amusicplayer,andsoforth.Infact,atypicalsystemmaybeseeminglyrunningtensorevenhundredsofprocessesatthesametime.Doingsomakesthesystemeasytouse,asoneneverneedbeconcernedwithwhetheraCPUisavailable;onesimplyrunsprograms.Henceourchallenge: THECRUXOFTHEPROBLEM:HOWTOPROVIDETHEILLUSIONOFMANYCPUS?AlthoughthereareonlyafewphysicalCPUsavailable,howcantheOSprovidetheillusionofanearly-endlesssupplyofsaidCPUs?TheOScreatesthisillusionbyvirtualizingtheCPU.Byrunningoneprocess,thenstoppingitandrunninganother,andsoforth,theOScanpromotetheillusionthatmanyvirtualCPUsexistwheninfactthereisonlyonephysicalCPU(orafew).Thisbasictechnique,knownastimesharingoftheCPU,allowsuserstorunasmanyconcurrentprocessesastheywouldlike;thepotentialcostisperformance,aseachwillrunmoreslowlyiftheCPU(s)mustbeshared.ToimplementvirtualizationoftheCPU,andtoimplementitwell,theOSwillneedbothsomelow-levelmachineryandsomehigh-levelin-telligence.Wecallthelow-levelmachinerymechanisms;mechanismsarelow-levelmethodsorprotocolsthatimplementaneededpieceoffunctionality.Forexample,we'lllearnlaterhowtoimplementacontext1 2THEABSTRACTION:THEPROCESS TIP:USETIMEHARING(ANDPACEHARING)TimesharingisabasictechniqueusedbyanOStosharearesource.Byallowingtheresourcetobeusedforalittlewhilebyoneentity,andthenalittlewhilebyanother,andsoforth,theresourceinquestion(e.g.,theCPU,oranetworklink)canbesharedbymany.Thecounterpartoftimesharingisspacesharing,wherearesourceisdivided(inspace)amongthosewhowishtouseit.Forexample,diskspaceisnaturallyaspace-sharedresource;onceablockisassignedtoale,itisnormallynotas-signedtoanotherleuntiltheuserdeletestheoriginalle.switch,whichgivestheOStheabilitytostoprunningoneprogramandstartrunninganotheronagivenCPU;thistime-sharingmechanismisemployedbyallmodernOSes.OntopofthesemechanismsresidessomeoftheintelligenceintheOS,intheformofpolicies.PoliciesarealgorithmsformakingsomekindofdecisionwithintheOS.Forexample,givenanumberofpossi-bleprogramstorunonaCPU,whichprogramshouldtheOSrun?AschedulingpolicyintheOSwillmakethisdecision,likelyusinghistori-calinformation(e.g.,whichprogramhasrunmoreoverthelastminute?),workloadknowledge(e.g.,whattypesofprogramsarerun),andperfor-mancemetrics(e.g.,isthesystemoptimizingforinteractiveperformance,orthroughput?)tomakeitsdecision.4.1TheAbstraction:AProcessTheabstractionprovidedbytheOSofarunningprogramissomethingwewillcallaprocess.Aswesaidabove,aprocessissimplyarunningprogram;atanyinstantintime,wecansummarizeaprocessbytakinganinventoryofthedifferentpiecesofthesystemitaccessesoraffectsduringthecourseofitsexecution.Tounderstandwhatconstitutesaprocess,wethushavetounderstanditsmachinestate:whataprogramcanreadorupdatewhenitisrunning.Atanygiventime,whatpartsofthemachineareimportanttotheexecu-tionofthisprogram?Oneobviouscomponentofmachinestatethatcomprisesaprocessisitsmemory.Instructionslieinmemory;thedatathattherunningpro-gramreadsandwritessitsinmemoryaswell.Thusthememorythattheprocesscanaddress(calleditsaddressspace)ispartoftheprocess.Alsopartoftheprocess'smachinestateareregisters;manyinstructionsexplicitlyreadorupdateregistersandthusclearlytheyareimportanttotheexecutionoftheprocess.Notethattherearesomeparticularlyspecialregistersthatformpartofthismachinestate.Forexample,theprogramcounter(PC)(sometimescalledtheinstructionpointerorIP)tellsuswhichinstructionofthepro-gramwillexecutenext;similarlyastackpointerandassociatedframeOPERATINGYSTEMS[VERSION1.01]WWW.OSTEP.ORG THEABSTRACTION:THEPROCESS3 TIP:SEPARATEPOLICYANDMECHANISMInmanyoperatingsystems,acommondesignparadigmistoseparatehigh-levelpoliciesfromtheirlow-levelmechanisms[L+75].Youcanthinkofthemechanismasprovidingtheanswertoahowquestionaboutasystem;forexample,howdoesanoperatingsystemperformacontextswitch?Thepolicyprovidestheanswertoawhichquestion;forexample,whichprocessshouldtheoperatingsystemrunrightnow?Separatingthetwoallowsoneeasilytochangepolicieswithouthavingtorethinkthemechanismandisthusaformofmodularity,ageneralsoftwaredesignprinciple.pointerareusedtomanagethestackforfunctionparameters,localvari-ables,andreturnaddresses.Finally,programsoftenaccesspersistentstoragedevicestoo.SuchI/Oinformationmightincludealistofthelestheprocesscurrentlyhasopen.4.2ProcessAPIThoughwedeferdiscussionofarealprocessAPIuntilasubsequentchapter,herewerstgivesomeideaofwhatmustbeincludedinanyinterfaceofanoperatingsystem.TheseAPIs,insomeform,areavailableonanymodernoperatingsystem.Create:Anoperatingsystemmustincludesomemethodtocre-atenewprocesses.Whenyoutypeacommandintotheshell,ordouble-clickonanapplicationicon,theOSisinvokedtocreateanewprocesstoruntheprogramyouhaveindicated.Destroy:Asthereisaninterfaceforprocesscreation,systemsalsoprovideaninterfacetodestroyprocessesforcefully.Ofcourse,manyprocesseswillrunandjustexitbythemselveswhencomplete;whentheydon't,however,theusermaywishtokillthem,andthusanin-terfacetohaltarunawayprocessisquiteuseful.Wait:Sometimesitisusefultowaitforaprocesstostoprunning;thussomekindofwaitinginterfaceisoftenprovided.MiscellaneousControl:Otherthankillingorwaitingforaprocess,therearesometimesothercontrolsthatarepossible.Forexample,mostoperatingsystemsprovidesomekindofmethodtosuspendaprocess(stopitfromrunningforawhile)andthenresumeit(con-tinueitrunning).Status:Thereareusuallyinterfacestogetsomestatusinformationaboutaprocessaswell,suchashowlongithasrunfor,orwhatstateitisin.c\r2008–19,ARPACI-DUSSEAUTHREEEASYPIECES 4THEABSTRACTION:THEPROCESS Memory CPU Disk codestatic dataheapstackProcess codestatic dataProgram Loading:Takes on-disk programand reads it into theaddress space of process Figure4.1:Loading:FromProgramToProcess4.3ProcessCreation:ALittleMoreDetailOnemysterythatweshouldunmaskabitishowprogramsaretrans-formedintoprocesses.Specically,howdoestheOSgetaprogramupandrunning?Howdoesprocesscreationactuallywork?TherstthingthattheOSmustdotorunaprogramistoloaditscodeandanystaticdata(e.g.,initializedvariables)intomemory,intothead-dressspaceoftheprocess.Programsinitiallyresideondisk(or,insomemodernsystems,ash-basedSSDs)insomekindofexecutableformat;thus,theprocessofloadingaprogramandstaticdataintomemoryre-quirestheOStoreadthosebytesfromdiskandplacetheminmemorysomewhere(asshowninFigure4.1).Inearly(orsimple)operatingsystems,theloadingprocessisdoneea-gerly,i.e.,allatoncebeforerunningtheprogram;modernOSesperformtheprocesslazily,i.e.,byloadingpiecesofcodeordataonlyastheyareneededduringprogramexecution.Totrulyunderstandhowlazyloadingofpiecesofcodeanddataworks,you'llhavetounderstandmoreaboutOPERATINGYSTEMS[VERSION1.01]WWW.OSTEP.ORG THEABSTRACTION:THEPROCESS5 themachineryofpagingandswapping,topicswe'llcoverinthefuturewhenwediscussthevirtualizationofmemory.Fornow,justrememberthatbeforerunninganything,theOSclearlymustdosomeworktogettheimportantprogrambitsfromdiskintomemory.Oncethecodeandstaticdataareloadedintomemory,thereareafewotherthingstheOSneedstodobeforerunningtheprocess.Somemem-orymustbeallocatedfortheprogram'srun-timestack(orjuststack).Asyoushouldlikelyalreadyknow,Cprogramsusethestackforlocalvariables,functionparameters,andreturnaddresses;theOSallocatesthismemoryandgivesittotheprocess.TheOSwillalsolikelyinitial-izethestackwitharguments;specically,itwillllintheparameterstothemain()function,i.e.,argcandtheargvarray.TheOSmayalsoallocatesomememoryfortheprogram'sheap.InCprograms,theheapisusedforexplicitlyrequesteddynamically-allocateddata;programsrequestsuchspacebycallingmalloc()andfreeitex-plicitlybycallingfree().Theheapisneededfordatastructuressuchaslinkedlists,hashtables,trees,andotherinterestingdatastructures.Theheapwillbesmallatrst;astheprogramruns,andrequestsmoremem-oryviathemalloc()libraryAPI,theOSmaygetinvolvedandallocatemorememorytotheprocesstohelpsatisfysuchcalls.TheOSwillalsodosomeotherinitializationtasks,particularlyasre-latedtoinput/output(I/O).Forexample,inUNIXsystems,eachprocessbydefaulthasthreeopenledescriptors,forstandardinput,output,anderror;thesedescriptorsletprogramseasilyreadinputfromtheterminalandprintoutputtothescreen.We'lllearnmoreaboutI/O,ledescrip-tors,andthelikeinthethirdpartofthebookonpersistence.Byloadingthecodeandstaticdataintomemory,bycreatingandini-tializingastack,andbydoingotherworkasrelatedtoI/Osetup,theOShasnow(nally)setthestageforprogramexecution.Itthushasonelasttask:tostarttheprogramrunningattheentrypoint,namelymain().Byjumpingtothemain()routine(throughaspecializedmechanismthatwewilldiscussnextchapter),theOStransferscontroloftheCPUtothenewly-createdprocess,andthustheprogrambeginsitsexecution.4.4ProcessStatesNowthatwehavesomeideaofwhataprocessis(thoughwewillcontinuetorenethisnotion),and(roughly)howitiscreated,letustalkaboutthedifferentstatesaprocesscanbeinatagiventime.Thenotionthataprocesscanbeinoneofthesestatesaroseinearlycomputersystems[DV66,V+65].Inasimpliedview,aprocesscanbeinoneofthreestates:Running:Intherunningstate,aprocessisrunningonaprocessor.Thismeansitisexecutinginstructions.Ready:Inthereadystate,aprocessisreadytorunbutforsomereasontheOShaschosennottorunitatthisgivenmoment.c\r2008–19,ARPACI-DUSSEAUTHREEEASYPIECES 6THEABSTRACTION:THEPROCESS RunningReady I/O: initiateI/O: done Figure4.2:Process:StateTransitionsBlocked:Intheblockedstate,aprocesshasperformedsomekindofoperationthatmakesitnotreadytorununtilsomeothereventtakesplace.Acommonexample:whenaprocessinitiatesanI/Orequesttoadisk,itbecomesblockedandthussomeotherprocesscanusetheprocessor.Ifweweretomapthesestatestoagraph,wewouldarriveatthedi-agraminFigure4.2.Asyoucanseeinthediagram,aprocesscanbemovedbetweenthereadyandrunningstatesatthediscretionoftheOS.Beingmovedfromreadytorunningmeanstheprocesshasbeensched-uled;beingmovedfromrunningtoreadymeanstheprocesshasbeendescheduled.Onceaprocesshasbecomeblocked(e.g.,byinitiatinganI/Ooperation),theOSwillkeepitassuchuntilsomeeventoccurs(e.g.,I/Ocompletion);atthatpoint,theprocessmovestothereadystateagain(andpotentiallyimmediatelytorunningagain,iftheOSsodecides).Let'slookatanexampleofhowtwoprocessesmighttransitionthroughsomeofthesestates.First,imaginetwoprocessesrunning,eachofwhichonlyusetheCPU(theydonoI/O).Inthiscase,atraceofthestateofeachprocessmightlooklikethis(Figure4.3).TimeProcess0Process1Notes 1RunningReady2RunningReady3RunningReady4RunningReadyProcess0nowdone5–Running6–Running7–Running8–RunningProcess1nowdoneFigure4.3:TracingProcessState:CPUOnlyOPERATINGYSTEMS[VERSION1.01]WWW.OSTEP.ORG THEABSTRACTION:THEPROCESS7 TimeProcess0Process1Notes 1RunningReady2RunningReady3RunningReadyProcess0initiatesI/O4BlockedRunningProcess0isblocked,5BlockedRunningsoProcess1runs6BlockedRunning7ReadyRunningI/Odone8ReadyRunningProcess1nowdone9Running–10Running–Process0nowdoneFigure4.4:TracingProcessState:CPUandI/OInthisnextexample,therstprocessissuesanI/Oafterrunningforsometime.Atthatpoint,theprocessisblocked,givingtheotherprocessachancetorun.Figure4.4showsatraceofthisscenario.Morespecically,Process0initiatesanI/Oandbecomesblockedwait-ingforittocomplete;processesbecomeblocked,forexample,whenread-ingfromadiskorwaitingforapacketfromanetwork.TheOSrecog-nizesProcess0isnotusingtheCPUandstartsrunningProcess1.WhileProcess1isrunning,theI/Ocompletes,movingProcess0backtoready.Finally,Process1nishes,andProcess0runsandthenisdone.NotethattherearemanydecisionstheOSmustmake,eveninthissimpleexample.First,thesystemhadtodecidetorunProcess1whileProcess0issuedanI/O;doingsoimprovesresourceutilizationbykeep-ingtheCPUbusy.Second,thesystemdecidednottoswitchbacktoProcess0whenitsI/Ocompleted;itisnotclearifthisisagooddeci-sionornot.Whatdoyouthink?ThesetypesofdecisionsaremadebytheOSscheduler,atopicwewilldiscussafewchaptersinthefuture.4.5DataStructuresTheOSisaprogram,andlikeanyprogram,ithassomekeydatastruc-turesthattrackvariousrelevantpiecesofinformation.Totrackthestateofeachprocess,forexample,theOSlikelywillkeepsomekindofpro-cesslistforallprocessesthatarereadyandsomeadditionalinforma-tiontotrackwhichprocessiscurrentlyrunning.TheOSmustalsotrack,insomeway,blockedprocesses;whenanI/Oeventcompletes,theOshouldmakesuretowakethecorrectprocessandreadyittorunagain.Figure4.5showswhattypeofinformationanOSneedstotrackabouteachprocessinthexv6kernel[CK+08].Similarprocessstructuresexistin“real”operatingsystemssuchasLinux,MacOSX,orWindows;lookthemupandseehowmuchmorecomplextheyare.Fromthegure,youcanseeacoupleofimportantpiecesofinforma-tiontheOStracksaboutaprocess.Theregistercontextwillhold,forac\r2008–19,ARPACI-DUSSEAUTHREEEASYPIECES 8THEABSTRACTION:THEPROCESS //theregistersxv6willsaveandrestore//tostopandsubsequentlyrestartaprocessstructcontext{inteip;intesp;intebx;intecx;intedx;intesi;intedi;intebp;};//thedifferentstatesaprocesscanbeinenumproc_state{UNUSED,EMBRYO,SLEEPING,RUNNABLE,RUNNING,ZOMBIE};//theinformationxv6tracksabouteachprocess//includingitsregistercontextandstatestructproc{char*mem;//Startofprocessmemoryuintsz;//Sizeofprocessmemorychar*kstack;//Bottomofkernelstack//forthisprocessenumproc_statestate;//Processstateintpid;//ProcessIDstructproc*parent;//Parentprocessvoid*chan;//If!zero,sleepingonchanintkilled;//If!zero,hasbeenkilledstructfile*ofile[NOFILE];//Openfilesstructinode*cwd;//Currentdirectorystructcontextcontext;//Switchheretorunprocessstructtrapframe*tf;//Trapframeforthe//currentinterrupt};Figure4.5:Thexv6ProcStructurestoppedprocess,thecontentsofitsregisters.Whenaprocessisstopped,itsregisterswillbesavedtothismemorylocation;byrestoringthesereg-isters(i.e.,placingtheirvaluesbackintotheactualphysicalregisters),theOScanresumerunningtheprocess.We'lllearnmoreaboutthistechniqueknownasacontextswitchinfuturechapters.Youcanalsoseefromthegurethattherearesomeotherstatesapro-cesscanbein,beyondrunning,ready,andblocked.Sometimesasystemwillhaveaninitialstatethattheprocessisinwhenitisbeingcreated.Also,aprocesscouldbeplacedinanalstatewhereithasexitedbutOPERATINGYSTEMS[VERSION1.01]WWW.OSTEP.ORG THEABSTRACTION:THEPROCESS9 ASIDE:DATATRUCTURE—THEPROCESSLISTOperatingsystemsarerepletewithvariousimportantdatastructuresthatwewilldiscussinthesenotes.Theprocesslist(alsocalledthetasklist)istherstsuchstructure.Itisoneofthesimplerones,butcertainlyanyOSthathastheabilitytorunmultipleprogramsatoncewillhavesomethingakintothisstructureinordertokeeptrackofalltherunningprogramsinthesystem.Sometimespeoplerefertotheindividualstruc-turethatstoresinformationaboutaprocessasaProcessControlBlock(PCB),afancywayoftalkingaboutaCstructurethatcontainsinforma-tionabouteachprocess(alsosometimescalledaprocessdescriptor).hasnotyetbeencleanedup(inUNIX-basedsystems,thisiscalledthezombiestate1).Thisnalstatecanbeusefulasitallowsotherprocesses(usuallytheparentthatcreatedtheprocess)toexaminethereturncodeoftheprocessandseeifthejust-nishedprocessexecutedsuccessfully(usually,programsreturnzeroinUNIX-basedsystemswhentheyhaveaccomplishedatasksuccessfully,andnon-zerootherwise).Whenn-ished,theparentwillmakeonenalcall(e.g.,wait())towaitforthecompletionofthechild,andtoalsoindicatetotheOSthatitcancleanupanyrelevantdatastructuresthatreferredtothenow-extinctprocess.4.6SummaryWehaveintroducedthemostbasicabstractionoftheOS:theprocess.Itisquitesimplyviewedasarunningprogram.Withthisconceptualviewinmind,wewillnowmoveontothenitty-gritty:thelow-levelmechanismsneededtoimplementprocesses,andthehigher-levelpoli-ciesrequiredtoscheduletheminanintelligentway.Bycombiningmech-anismsandpolicies,wewillbuildupourunderstandingofhowanoper-atingsystemvirtualizestheCPU. 1Yes,thezombiestate.Justlikerealzombies,thesezombiesarerelativelyeasytokill.However,differenttechniquesareusuallyrecommended.c\r2008–19,ARPACI-DUSSEAUTHREEEASYPIECES 10THEABSTRACTION:THEPROCESS ASIDE:KEYPROCESSTERMSTheprocessisthemajorOSabstractionofarunningprogram.Atanypointintime,theprocesscanbedescribedbyitsstate:thecon-tentsofmemoryinitsaddressspace,thecontentsofCPUregisters(includingtheprogramcounterandstackpointer,amongothers),andinformationaboutI/O(suchasopenleswhichcanbereadorwritten).TheprocessAPIconsistsofcallsprogramscanmakerelatedtopro-cesses.Typically,thisincludescreation,destruction,andotheruse-fulcalls.Processesexistinoneofmanydifferentprocessstates,includingrunning,readytorun,andblocked.Differentevents(e.g.,gettingscheduledordescheduled,orwaitingforanI/Otocomplete)tran-sitionaprocessfromoneofthesestatestotheother.Aprocesslistcontainsinformationaboutallprocessesinthesys-tem.Eachentryisfoundinwhatissometimescalledaprocesscontrolblock(PCB),whichisreallyjustastructurethatcontainsinformationaboutaspecicprocess.OPERATINGYSTEMS[VERSION1.01]WWW.OSTEP.ORG THEABSTRACTION:THEPROCESS11 References[BH70]“TheNucleusofaMultiprogrammingSystem”byPerBrinchHansen.Communica-tionsoftheACM,Volume13:4,April1970.Thispaperintroducesoneoftherstmicrokernelsinoperatingsystemshistory,calledNucleus.Theideaofsmaller,moreminimalsystemsisathemethatrearsitsheadrepeatedlyinOShistory;itallbeganwithBrinchHansen'sworkdescribedherein.[CK+08]“Thexv6OperatingSystem”byRussCox,FransKaashoek,RobertMorris,NickolaiZeldovich.From:https://github.com/mit-pdos/xv6-public.ThecoolestrealandlittleOSintheworld.Downloadandplaywithittolearnmoreaboutthedetailsofhowoperatingsystemsactuallywork.Wehavebeenusinganolderversion(2012-01-30-1-g1c41342)andhencesomeexamplesinthebookmaynotmatchthelatestinthesource.[DV66]“ProgrammingSemanticsforMultiprogrammedComputations”byJackB.Dennis,EarlC.VanHorn.CommunicationsoftheACM,Volume9,Number3,March1966.Thispaperdenedmanyoftheearlytermsandconceptsaroundbuildingmultiprogrammedsystems.[L+75]“Policy/mechanismseparationinHydra”byR.Levin,E.Cohen,W.Corwin,F.Pollack,W.Wulf.SOSP'75,Austin,Texas,November1975.Anearlypaperabouthowtostructureoperat-ingsystemsinaresearchOSknownasHydra.WhileHydraneverbecameamainstreamOS,someofitsideasinuencedOSdesigners.[V+65]“StructureoftheMulticsSupervisor”byV.A.Vyssotsky,F.J.Corbato,R.M.Graham.FallJointComputerConference,1965.AnearlypaperonMultics,whichdescribedmanyofthebasicideasandtermsthatwendinmodernsystems.Someofthevisionbehindcomputingasautilityarenallybeingrealizedinmoderncloudsystems.c\r2008–19,ARPACI-DUSSEAUTHREEEASYPIECES 12THEABSTRACTION:THEPROCESS Homework(Simulation)Thisprogram,process-run.py,allowsyoutoseehowprocessstateschangeasprogramsrunandeitherusetheCPU(e.g.,performanaddinstruction)ordoI/O(e.g.,sendarequesttoadiskandwaitforittocomplete).SeetheREADMEfordetails.Questions1.Runprocess-run.pywiththefollowingags:-l5:100,5:100.WhatshouldtheCPUutilizationbe(e.g.,thepercentoftimetheCPUisinuse?)Whydoyouknowthis?Usethe-cand-pagstoseeifyouwereright.2.Nowrunwiththeseags:./process-run.py-l4:100,1:0.Theseagsspecifyoneprocesswith4instructions(alltousetheCPU),andonethatsimplyissuesanI/Oandwaitsforittobedone.Howlongdoesittaketocompletebothprocesses?Use-cand-ptondoutifyouwereright.3.Switchtheorderoftheprocesses:-l1:0,4:100.Whathappensnow?Doesswitchingtheordermatter?Why?(Asalways,use-cand-ptoseeifyouwereright)4.We'llnowexploresomeoftheotherags.Oneimportantagis-S,whichdetermineshowthesystemreactswhenaprocessis-suesanI/O.WiththeagsettoSWITCH ON END,thesystemwillNOTswitchtoanotherprocesswhileoneisdoingI/O,in-steadwaitinguntiltheprocessiscompletelynished.Whathap-penswhenyourunthefollowingtwoprocesses(-l1:0,4:100-c-SSWITCH ON END),onedoingI/OandtheotherdoingCPUwork?5.Now,runthesameprocesses,butwiththeswitchingbehaviorsettoswitchtoanotherprocesswheneveroneisWAITINGforI/O(-l1:0,4:100-c-SSWITCH ON IO).Whathappensnow?Use-cand-ptoconrmthatyouareright.6.OneotherimportantbehavioriswhattodowhenanI/Ocom-pletes.With-IIO RUN LATER,whenanI/Ocompletes,thepro-cessthatissueditisnotnecessarilyrunrightaway;rather,whateverwasrunningatthetimekeepsrunning.Whathappenswhenyourunthiscombinationofprocesses?(Run./process-run.py-l3:0,5:100,5:100,5:100-SSWITCH ON IO-IIO RUN LATER-c-p)Aresystemresourcesbeingeffectivelyutilized?7.Nowrunthesameprocesses,butwith-IIO RUN IMMEDIATEset,whichimmediatelyrunstheprocessthatissuedtheI/O.Howdoesthisbehaviordiffer?Whymightrunningaprocessthatjustcom-pletedanI/Oagainbeagoodidea?OPERATINGYSTEMS[VERSION1.01]WWW.OSTEP.ORG THEABSTRACTION:THEPROCESS13 8.Nowrunwithsomerandomlygeneratedprocesses:-s1-l3:50,3:50or-s2-l3:50,3:50or-s3-l3:50,3:50.Seeifyoucanpredicthowthetracewillturnout.Whathappenswhenyouusetheag-IIO RUN IMMEDIATEvs.-IIO RUN LATER?Whathap-penswhenyouuse-SSWITCH ON IOvs.-SSWITCH ON END?c\r2008–19,ARPACI-DUSSEAUTHREEEASYPIECES