Google云计算课程-Module2-StudentBackgroundKnowledge.ppt

上传人:tia****nde 文档编号:11496367 上传时间:2020-04-25 格式:PPT 页数:40 大小:925KB
返回 下载 相关 举报
Google云计算课程-Module2-StudentBackgroundKnowledge.ppt_第1页
第1页 / 共40页
Google云计算课程-Module2-StudentBackgroundKnowledge.ppt_第2页
第2页 / 共40页
Google云计算课程-Module2-StudentBackgroundKnowledge.ppt_第3页
第3页 / 共40页
点击查看更多>>
资源描述
SpinnakerLabs,Inc.,GoogleClusterComputingFacultyTrainingWorkshop,ModuleII:StudentBackgroundKnowledge,ThispresentationincludescoursecontentUniversityofWashingtonRedistributedundertheCreativeCommonsAttribution3.0license.Allothercontents:,SpinnakerLabs,Inc.,BackgroundTopics,ProgrammingLanguagesSystems:OperatingSystemsFileSystemsNetworkingDatabases,SpinnakerLabs,Inc.,ProgrammingLanguages,MapReduceisbasedonfunctionalprogrammingmapandfoldFPistaughtinonequarter,butnotreinforced“Crashcourse”necessaryWorksheetstoposeshortproblemsintermsofmapandfoldImmutabledataakeyconcept,SpinnakerLabs,Inc.,Multithreadedprogramming,TaughtinOScourseatWashingtonNotaprerequisite!Studentsneedtounderstandmultiplecopiesofsamemethodrunninginparallel,SpinnakerLabs,Inc.,FileSystems,NecessarytounderstandGFSComparisontoNFS,otherdistributedfilesystemsrelevant,SpinnakerLabs,Inc.,Networking,TCP/IPConceptsof“connection,”networksplits,otherfailuremodesBandwidthissues,SpinnakerLabs,Inc.,OtherSystemsTopics,ProcessSchedulingSynchronizationMemorycoherency,SpinnakerLabs,Inc.,Databases,ConceptofsharedconsistencymodelConsensusACIDcharacteristicsJournalingMulti-phasecommitprocesses,SpinnakerLabs,Inc.,Parallelizationy=x;,Thread2:voidbar()y+;x+;,Iftheinitialstateisy=0,x=6,whathappensafterthesethreadsfinishrunning?,Multithreaded=Unpredictability,Whenwerunamultithreadedprogram,wedontknowwhatorderthreadsrunin,nordoweknowwhentheywillinterruptoneanother.,Thread1:voidfoo()eax=memx;inceax;memx=eax;ebx=memx;memy=ebx;,Thread2:voidbar()eax=memy;inceax;memy=eax;eax=memx;inceax;memx=eax;,Manythingsthatlooklike“onestep”operationsactuallytakeseveralstepsunderthehood:,SpinnakerLabs,Inc.,Multithreaded=Unpredictability,Thisappliestomorethanjustintegers:PullingworkunitsfromaqueueReportingworkbacktomasterunitTellinganotherthreadthatitcanbeginthe“nextphase”ofprocessingAllrequiresynchronization!,SpinnakerLabs,Inc.,SynchronizationPrimitives,Asynchronizationprimitiveisaspecialsharedvariablethatguaranteesthatitcanonlybeaccessedatomically.Hardwaresupportguaranteesthatoperationsonsynchronizationprimitivesonlyevertakeonestep,Semaphores,AsemaphoreisaflagthatcanberaisedorloweredinonestepSemaphoreswereflagsthatrailroadengineerswouldusewhenenteringasharedtrack,Onlyonesideofthesemaphorecaneverbered!(Canbothbegreen?),SpinnakerLabs,Inc.,Semaphores,set()andreset()canbethoughtofaslock()andunlock()Callstolock()whenthesemaphoreisalreadylockedcausethethreadtoblock.Pitfalls:Must“bind”semaphorestoparticularobjects;mustremembertounlockcorrectly,SpinnakerLabs,Inc.,The“Corrected”Example,Thread1:voidfoo()sem.lock();x+;y=x;sem.unlock();,Thread2:voidbar()sem.lock();y+;x+;sem.unlock();,Globalvar“Semaphoresem=newSemaphore();”guardsaccesstoxx+;y=x;fooDone=true;sem.unlock();fooFinishedCV.notify();,Thread2:voidbar()sem.lock();while(!fooDone)fooFinishedCV.wait(sem);y+;x+;sem.unlock();,Globalvars:Semaphoresem=newSemaphore();ConditionVarfooFinishedCV=newConditionVar();booleanfooDone=false;,SpinnakerLabs,Inc.,Barriers,Abarrierknowsinadvancehowmanythreadsitshouldwaitfor.Threads“register”withthebarrierwhentheyreachit,andfallasleep.BarrierwakesupallregisteredthreadswhentotalcountiscorrectPitfall:Whathappensifathreadtakesalongtime?,SpinnakerLabs,Inc.,TooMuchSynchronization?Deadlock,SynchronizationbecomesevenmorecomplicatedwhenmultiplelockscanbeusedCancauseentiresystemto“getstuck”,ThreadA:semaphore1.lock();semaphore2.lock();/*usedataguardedbysemaphores*/semaphore1.unlock();semaphore2.unlock();,ThreadB:semaphore2.lock();semaphore1.lock();/*usedataguardedbysemaphores*/semaphore1.unlock();semaphore2.unlock();,(Image:RPICSCI.4210OperatingSystemsnotes),SpinnakerLabs,Inc.,AndifyouthoughtIwasjoking,SpinnakerLabs,Inc.,TheMoral:BeCareful!,SynchronizationishardNeedtoconsiderallpossiblesharedstateMustkeeplocksorganizedandusethemconsistentlyandcorrectlyKnowingtherearebugsmaybetricky;fixingthemcanbeevenworse!Keepingsharedstatetoaminimumreducestotalsystemcomplexity,SpinnakerLabs,Inc.,FundamentalsofNetworking,SpinnakerLabs,Inc.,Sockets:TheInternet=tubes?,AsocketisthebasicnetworkinterfaceProvidesatwo-way“pipe”abstractionbetweentwoapplicationsClientcreatesasocket,andconnectstotheserver,whoreceivesasocketrepresentingtheotherside,SpinnakerLabs,Inc.,Ports,WithinanIPaddress,aportisasub-addressidentifyingalisteningprogramAllowsmultipleclientstoconnecttoaserveratonce,SpinnakerLabs,Inc.,Example:WebServer(1/3),Theservercreatesalistenersocketattachedtoaspecificport.80istheagreed-uponportnumberforwebtraffic.,SpinnakerLabs,Inc.,Example:WebServer(2/3),Theclient-sidesocketisstillconnectedtoaport,buttheOSchoosesarandomunusedportnumberWhentheclientrequestsaURL(e.g.,“”),itsOSusesasystemcalledDNStofinditsIPaddress.,SpinnakerLabs,Inc.,Example:WebServer(3/3),Serverchoosesarandomly-numberedporttohandlethisparticularclientListenerisreadyformoreincomingconnections,whileweprocessthecurrentconnectioninparallel,Whatmakesthiswork?,UnderneaththesocketlayerareseveralmoreprotocolsMostimportantareTCPandIP(whichareusedhand-in-handsooften,theyreoftenspokenofasoneprotocol:TCP/IP),Evenmorelow-levelprotocolshandlehowdataissentoverEthernetwires,orhowbitsaresentthroughtheairusing802.11wireless,SpinnakerLabs,Inc.,IP:TheInternetProtocol,DefinestheaddressingschemeforcomputersEncapsulatesinternaldataina“packet”DoesnotprovidereliabilityJustincludesenoughinformationforthedatatotellrouterswheretosendit,SpinnakerLabs,Inc.,TCP:TransmissionControlProtocol,BuiltontopofIPIntroducesconceptof“connection”Providesreliabilityandordering,SpinnakerLabs,Inc.,WhyisThisNecessary?,Notactuallytube-like“underneaththehood”Unlikephonesystem(circuitswitched),thepacketswitchedInternetusesmanyroutesatonce,SpinnakerLabs,Inc.,NetworkingIssues,Ifapartytoasocketdisconnects,howmuchdatadidtheyreceive?Didtheycrash?Ordidamachineinthemiddle?Cansomeoneinthemiddleintercept/modifyourdata?Trafficcongestionmakesswitch/routertopologyimportantforefficientthroughput,SpinnakerLabs,Inc.,FinalThoughts,VariousbackgroundtopicsfitintothiscourseTwoexampleshighlightedOtherbackgroundtopicsmaybenefitfromexpansion,worksheets,reinforcement,
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 图纸专区 > 课件教案


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!