Ex3Word文档下载推荐.docx
《Ex3Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《Ex3Word文档下载推荐.docx(9页珍藏版)》请在冰豆网上搜索。
d.Whatisathread?
Neweroperatingsystemsprovidethreadswhichallliveinthesameaddressspaceandsharetheirfiledescriptors.Thethreadcanbedefinedasaseparatestreamofexecutionthattakesplacesimultaneouslywithandindependentlyofeverythingelsethatmightbehappening.
e.Whyarethreadsuseful?
Firstly,itspendslesstimetocreateanewthreadthanaprocesswiththereasonthatthenewlycreatedthreadonlyusesthecurrentprocessaddressspace,buttheprocessnot.
Secondly,itisquickertoendathreadthanaprocess.Becausethethreadsoccurinthesamecurrentprocessaddress,soitisquickertoswitchbetweenthreadsthanprocesses.
Thirdly,forthesamereasonmentionedabove,thedatawhichareproducedbyonethreadcanbesharedbyanotherthreadimmediately,alsomuchfasterthanprocesses.
NowletustryusingtheTimestampprogramandruntwothreads.
Right-clickonTimestamp.exeandsaveprogramindriveC.ThisprogramshouldbeexecutedintheWindowscommandconsole.OpentheWindowscommandconsolebyclickingontheStartmenuondesktop,andthenselectRun...Type"
cmd"
inthetextfieldandclickOK.AtthepromptC:
\,type"
Timestamp–i500000–p2>
Output.out"
;
pressENTER.
Note:
-ispecifiesthenumberofworkcycles,and-pspecifiesthenumberofthreadstorun.
Nowusethegraphicalinterfacetoseetheoutput.
Right-clickonGraph.exeandsavetheprograminDriveC.Opentheprogram.IfGraph.exedoesnotrun,refertoAppendixA.RunningaVisualBasicFileforinstructions.OnceGraph.exeisopened,clickSelectDataFile,andchoosethefileOutput.outindriveC.
Notethatthehorizontalaxisisthenumberofworkcycles.Eachthreadisdistinguishedbyadifferentcolor.Thegrayareasindicatethatthesystemisnotrunningthegiventhreads.Alegendforthethreadsisdisplayedatthebottomofthegraph.
f.Captureascreenshotofthegraphicaloutput.
g.Listtheorderinwhichthethreadsarebeingexecuted.
1-1-2-2-1-1-2
h.Whatisacontextswitch?
Howdoyouknowacontextswitchoccurredfromthegraph?
WhenswitchingtheCPUtoanotherprocessrequiressavingthestateoftheoldprocessandloadingthesavedstateforthenewprocess,whichisknownasacontextswitch.Acontextusuallyoccurswhenaninterruptappearsonthescreen.
i.Whatactivitiesareperformedbytheprocessorduringacontextswitch?
AninterruptoccursanditwilldosomethingtomakingnotesoftheaddressofthelastinstructionexecutedandthenswitchCPUtoanotherprocess.
j.Explainwhatishappeningintermsofpreemptivemultitaskingandwhateffectithastotheuser.
Theprocessorcanassigndifferentprioritiestodifferenttypesofinterrupts.Thelow-speeddeviceshavelowpriorityandthehigh-speeddeviceshavehighpriority.Thehighprioritydevicescaninterruptthelowprioritydevicesbutthelowprioritydevicescan’tinterruptthehighprioritydevices.
k.Aninterruptindicatesthatthethreadisnotbeingrunandshouldthereforebefollowedbyagraygap.Howdoesthekernelhandleaninterrupt?
Atfirst,theinputdevicesendstotheprocessoranIRQ.WhentheprocessorreceivesthissignalofIRQ,itstopsexecutingtheapplicationprogram,makingnotesoftheaddressofthelastinstructionexecuted.Then,itswitchestotheaddressoftheinterrupthandy,andstartsexecutingtheinstructionswhereitfinds.
Tryusingmorethantwothreads.
AttheWindowscommandpromptC:
\,type“Timestamp–i500000–p[enterthenumberofthreadstorun(lessthan10)]”andpressENTER.
l.Copyandpastethegraphicaloutput.
m.Listtheorderinwhichthethreadsarebeingexecuted.
1-2-1-1-2-3-4-4-5-5-5-3-4-4-5-6-7-7-8-6-7-8-9
n.Considerasetofthreeprocessesthatareexecutedtocompletion.ProcessAtakes6seconds,ProcessBtakes3seconds,andProcessCtakes5seconds.Abouthowlongwouldittakeforalltheprocessestobecompletedusingpreemptivemultitasking,morethan14seconds,lessthan14seconds,orexactly14seconds?
Explainyouranswer.
Morethan14seconds,becausethecontextswitchesalsocosttimes
Nowinvestigateyourownsystem.
o.HowmuchRAM(mainmemory)doesyourmachinehave?
Showproofofyouranswerbysubmittingascreenshotofthedisplayfromwhichyouinferredyouranswer.
512M
LaunchMicrosoftWordifitisnotalreadylaunched.
p.HowmanythreadsdoesMicrosoftWordlaunch?
(Referto3.1.4Lab:
TheTaskManager.)Showproofofyouranswerbysubmittingascreenshotofthedisplayfromwhichyouinferredyouranswer.
10
q.HowmuchmemorydoesMicrosoftWordconsume?
Showproofofyouranswerbysubmittingascreenshotofthedisplayfromwhichyouinferredyouranswer.
27368KB
Question2.VirtualMemory
Inthissection,youwilluseaprogramdemonstratinghowvirtualmemoryisused.
a.Howdoesvirtualmemoryworkusingapagetable?
Wheninvirtualmemory,everyaddresscanbetranslatedintoaphysicalmemoryaddressbyapagetable.Foreverypageinthevirtualaddressspace,thepagetablegivestherealaddressinRAMwherethepageislocated.
b.Whatistheprimarypurposeofvirtualmemory?
Itcan“add”thestorageofthememorywhichmeanstheprogramcanbelocatedflexibly.
c.Listthreeadvantagesofusingvirtualmemorywhenexecutingaprogram.
Firstly,theaddressspacetheprocessesassigncanactuallybe“larger”thanthephysicalmemoryavailable.
Secondly,inasystemthatusesvirtualmemory,everyprogramrunsinitsownprivateaddressspace.
Thirdly,usingthevirtualmemoryscheme,asmallamountofRAMisrequiredforaprogramtorun,andtherestoftheprogramsaddressspaceiskeptonthedisk
ExecutethePageReplacementSimulationprogram.
ClickonPaging.exetoruntheapplication.RefertoAppendixA.RunningaVisualBasicFileifPaging.exedoesnotrun.
Noticethetopoftheprogramwindowindicatesthenumberofrequestandtotalpagefaults.ThetableontheleftrepresentsRAMandtheoneontherightrepresentstheharddisk.Theorderofrequestsissetatdefault.Youcanalsoenteryourownorderofrequests.Tochangethespeedofthesimulation,youcanusethespeedadjusteratthebottom-leftoftheprogramwindow.EachtimeyouclickonStoporPause,thesimulationendsafteronecompletememoryaccess.
Starttheprogramusingthedefaultqueueofrequests.
d.Describewhatishappeningforthefirstsevenrequestsstep-by-stepforthedefaultorderofrequests.
Therearefivepagefaults,whichmeansfourrequestsisinvirtualmemory.Atfirst,thecomputerstaketherequesttoRAMandthensendittoCPU.
e.Whendoesapagefaultoccur,andhowdoesthekernelhandleapagefault?
TheaddresstranslationcircuitrychecksthepagetablebutfindsthepageisnotinRAM,soitstartsapagefault(aninterrupt).Thentheprocessorstopsexecutingtheuserprogramandswitchthecontroltothekernel.Thekernellooksatcertainstatusregisterstomakeclearthatwherethepagefaultcamefromandknowtheprocesswantsaccesstoitsvirtualpage,soitwillgiveRAMandloadinthepagefortheprogram.Afterthatitwillfixupdatethepagetable.Afterawhile,controlwillbereturnedtotheuserprogram.
f.Enterasequenceofeightrequestsinplaceofthedefaultorderofrequestsintheprogramthatwouldcausefourpagefaults.
1,2,3,4,1,2,3,4
g.Inwhatcaseisitundesirabletousevirtualmemory?
Thespeedmaybecomeverylow.
h.Givenatotalpagingfilesizeof267MB,andaRAMofsize256MB.Yourapplicationsarecurrentlytakingup500MBofmemory.Howwouldyourunanapplicationthatconsumes100MBofmemory?
Wecanexpandthevirtualmemory.
Question3.Troubleshooting
Belowarevariousproblemscenarios.Selectthemostlikelycause(s)fortheproblemfromtheCauseslist.
Causes
A.Componentnotpluggedin
B.Applicationsoftwareerror
C.Operatingsystemerror
D.LowRAM
E.Slowprocessor
F.CMOSbatteryfailure
G.Motherboardfailure
H.Harddiskfailure
I.BIOSROMfailure
J.Appropriatecomponentdrivernotinstalledproperly
Problems
a.Programnotresponding
Causes:
D.LowRAMorE.Slowprocessor
b.Screenfrozeaftersuccessfullybooting
C.Operatingsystemerror
c.Programsrunningslowly
d.Peripheraldevicenotworking(mouse,keyboard,printer)
A.ComponentnotpluggedinorJ.Appropriatecomponentdrivernotinstalledproperly
e.Allnecessarycomputersystemcomponentsarepluggedin,butthesystemdoesnotboot
F.CMOSbatteryfailureorG.MotherboardfailureorI.BIOSROMfailure.
f.Thecomputerisbeingbooted,andanerrormessageindicatesthattheharddrivecannotbefound.
H.Harddiskfailure
g.Iflowmemoryisacauseofthesystemrunningslowly,whatcanyoudoasausertospeedupthesystem?
Expandingthestorageofthemainmemoryandthevirtualmemory,whichIthinkisthemostimportant.
Question4.FileDirectories
Inthisquestion,youaregivenazipfile,whichcontainssomefoldersandfiles.Youwillunzipthegivenfile,manipulatethefilesandfolders