




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
ParallelProgrammingInstructor:ZhangWeizhe(張偉哲)ComputerNetworkandInformationSecurityTechniqueResearchCenter,SchoolofComputerScienceandTechnology,HarbinInstituteofTechnologyConsistency3Data-CentricConsistencyModelsI.e.,trytokeepdataconsistentacrossreplicasClient-CentricConsistencyModelsWeakerconditionOnlymaintainconsistencyforeachclientseparatelyOutline4以數據為中心的一致性模型即,嘗試使數據在復制品上保持一致以客戶為中心的一致性模型條件較弱只保持每個客戶端的一致性Outline5Data-CentricConsistencyModelsConsistencymodel(akaconsistencysemanticsorconstraints)ContractbetweenprocessesandthedatastoreIfprocessesobeycertainrules,datastorewillworkcorrectlyAllmodelsattempttoreturntheresultsofthelastwriteforareadoperationDifferinhow“l(fā)ast”writeisdetermined/defined6以數據為中心的一致性模型一致性模型(一致性語義或約束)流程和數據存儲之間的契約如果流程遵守某些規(guī)則,數據存儲將正常工作所有模型都嘗試返回最后寫入的結果,以進行讀取操作不同之處是“最后”寫入如何確定/定義的7StrictConsistencyAnyreadalwaysreturnstheresultofthemostrecentwriteImplicitlyassumesthepresenceofaglobalclockAwriteisimmediatelyvisibletoallprocessesDifficulttoachieveinrealsystemsasnetworkdelayscanbevariable(a)Astrictlyconsistentstore.(b)Astorethatisnotstrictlyconsistent.8嚴格一致任何讀取總是返回最近寫入的結果隱含地假定存在全局時鐘所有進程都可以立即看到寫入在實際系統(tǒng)中難以實現(xiàn),因為網絡延遲是可變的(a)Astrictlyconsistentstore.(b)Astorethatisnotstrictlyconsistent.9SequentialConsistency(1)Adatastoreissequentiallyconsistentwhen:Theresultofanyexecutionisthesameasifthe(readandwrite)operationsbyallprocessesonthedatastore…wereexecutedinsomesequentialorderand…theoperationsofeachindividualprocessappear…inthissequenceintheorderspecifiedbyitsprogram.10順序一致性(1)數據存儲是順序一致的:
任何執(zhí)行的結果與數據存儲上的所有進程的(讀取和寫入)操作相同...被執(zhí)行了一些順序...每個進程的操作出現(xiàn)...以這個順序按其程序指定的順序。11SequentialConsistency(2)Sequentialconsistency:weakerthanstrictconsistencyAssumesalloperationsareexecutedinsomesequentialorderandeachprocessissuesoperationsinprogramorderAnyvalidinterleavingisallowed AllagreeonthesameinterleavingEachprocesspreservesitsprogramorderNothingissaidabout“mostrecentwrite”12順序一致性(2)順序一致性:弱于嚴格的一致性假設所有操作都按照一定順序執(zhí)行,每個進程按程序順序發(fā)出操作允許任何有效的交織所有人都同意相同的交錯每個進程保留其程序順序沒有關于“最近寫的”13SequentialConsistency(3)(a)Asequentiallyconsistentdatastore.
(b)Adatastorethatisnotsequentiallyconsistent.14順序一致性(3)(a)順序一致的數據存儲。(b)不是順序一致的數據存儲。15CasualConsistency(1)Necessarycondition:
Writesthatarepotentiallycasuallyrelatedmustbeseenbyallprocessesinthesameorder.Concurrentwritesmaybeseeninadifferentorderondifferentmachines.Causallyrelatedwritesmustbeseenbyallprocessesinthesameorder.Concurrentwritesmaybeseenindifferentordersondifferentmachines16結果一致性(1)必要條件:
可能的相關隨機寫入必須以相同的順序被所有進程看到。并行寫入可以在不同的機器上以不同的順序看到。所有進程必須以相同的順序看到結果相關的寫入。并行寫入可以在不同的機器上以不同的順序看到17CasualConsistency(2)Thissequenceisallowedwithacasually-consistentstore,butnotwithsequentiallyorstrictlyconsistentstore.18結果一致性(2)這個序列允許隨機一致的存儲,但不是按順序或嚴格一致的存儲。19CasualConsistency(3)Aviolationofacasually-consistentstore.Acorrectsequenceofeventsinacasually-consistentstore.20結果一致性(3)一個違反結果一致的存儲一個符合結果一致的正確存儲序列21FIFOConsistency(1)NecessaryCondition:
Writesdonebyasingleprocessareseenbyallotherprocessesintheorderinwhichtheywereissued,butwritesfromdifferentprocessesmaybeseeninadifferentorderbydifferentprocesses.22FIFOConsistency(1)必要條件:所有其他進程按單個進程執(zhí)行的寫入按照發(fā)布順序可以看到,但不同進程的寫入可能按不同的進程以不同的順序顯示。23FIFOConsistency(2)AvalidsequenceofeventsofFIFOconsistency24FIFOConsistency(2)AvalidsequenceofeventsofFIFOconsistency25WeakConsistency(1)Properties:AccessestosynchronizationvariablesassociatedwithadatastorearesequentiallyconsistentNooperationonasynchronizationvariableisallowedtobeperformeduntilallpreviouswriteshavebeencompletedeverywhereNoreadorwriteoperationondataitemsareallowedtobeperformeduntilallpreviousoperationstosynchronizationvariableshavebeenperformed.26弱一致性(1)屬性:訪問與數據存儲相關聯(lián)的同步變量是順序一致的允許執(zhí)行同步變量的操作,直到所有以前的寫入都到處都完成在執(zhí)行對同步變量的所有先前操作之前,都不允許執(zhí)行對數據項的讀取或寫入操作。27WeakConsistency(2)Avalidsequenceofeventsforweakconsistency.Aninvalidsequenceforweakconsistency.28ReleaseConsistency(1)Avalideventsequenceforreleaseconsistency.29ReleaseConsistency(2)Rules:Beforeareadorwriteoperationonshareddataisperformed,allpreviousacquiresdonebytheprocessmusthavecompletedsuccessfully.Beforeareleaseisallowedtobeperformed,allpreviousreadsandwritesbytheprocessmusthavecompletedAccessestosynchronizationvariablesareFIFOconsistent(sequentialconsistencyisnotrequired).30ReleaseConsistency(2)規(guī)則:在執(zhí)行對共享數據的讀或寫操作之前,進程完成的所有以前的獲取必須已經成功完成。在允許執(zhí)行釋放之前,進程的所有以前的讀取和寫入都必須已經完成訪問同步變量是FIFO一致的(不需要順序一致性)。31EntryConsistency(1)Conditions:Anacquireaccessofasynchronizationvariableisnotallowedtoperformwithrespecttoaprocessuntilallupdatestotheguardedshareddatahavebeenperformedwithrespecttothatprocess.Beforeanexclusivemodeaccesstoasynchronizationvariablebyaprocessisallowedtoperformwithrespecttothatprocess,nootherprocessmayholdthesynchronizationvariable,noteveninnonexclusivemode.Afteranexclusivemodeaccesstoasynchronizationvariablehasbeenperformed,anyotherprocess'snextnonexclusivemodeaccesstothatsynchronizationvariablemaynotbeperformeduntilithasperformedwithrespecttothatvariable'sowner.32準入一致性(1)條件:不允許同步變量的獲取訪問相對于進程執(zhí)行,直到對該進程已經執(zhí)行了對被保護的共享數據的所有更新。在允許進程對異步模式訪問同步變量進行相對于該進程的執(zhí)行之前,沒有其他進程可能保持同步變量,甚至不是非排他性的模式。在執(zhí)行對同步變量的獨占模式訪問之后,任何其他進程的下一個非排他性模式對該同步變量的訪問可能不會執(zhí)行,直到相對于該變量的所有者執(zhí)行。33EntryConsistency(2)Avalideventsequenceforentryconsistency.34EntryConsistency(2)Avalideventsequenceforentryconsistency.35SummaryofConsistencyModelsConsistencyDescriptionStrictAbsolutetimeorderingofallsharedaccessesmatters.LinearizabilityAllprocessesmustseeallsharedaccessesinthesameorder.Accessesarefurthermoreorderedaccordingtoa(nonunique)globaltimestampSequentialAllprocessesseeallsharedaccessesinthesameorder.AccessesarenotorderedintimeCausalAllprocessesseecausally-relatedsharedaccessesinthesameorder.FIFOAllprocessesseewritesfromeachotherintheordertheywereused.Writesfromdifferentprocessesmaynotalwaysbeseeninthatorder(a)ConsistencymodelsnotusingsynchronizationoperationsConsistencyDescriptionWeakShareddatacanbecountedontobeconsistentonlyafterasynchronizationisdoneReleaseShareddataaremadeconsistentwhenacriticalregionisexitedEntryShareddatapertainingtoacriticalregionaremadeconsistentwhenacriticalregionisentered.(b)Modelswithsynchronizationoperations.36SummaryofConsistencyModelsConsistencyDescriptionStrict共享事務按絕對時間組織Linearizability所有進程必須以相同的順序查看所有共享訪問。還可以根據(非唯一)全局時間戳對訪問進行排序Sequential所有進程以相同的順序查看所有共享訪問。訪問不記錄Causal所有進程都以相同的順序查看結果相關的共享訪問。FIFO所有進程按照它們使用的順序相互寫入。來自不同進程的寫入可能并不總是以該順序被看到(a)不使用同步操作的一致性模型ConsistencyDescriptionWeak只有在同步完成后,共享數據才能被統(tǒng)計為一致Release當退出關鍵區(qū)域時,共享數據保持一致Entry關鍵區(qū)域的共享數據在進入關鍵區(qū)域時保持一致。
(b)使用同步操作的一致性模型37Data-CentricConsistencyModelsI.e.,trytokeepdataconsistentacrossreplicasClient-CentricConsistencyModelsWeakerconditionOnlymaintainconsistencyforeachclientseparatelyOutline38以數據為中心的一致性模型即,嘗試使數據在復制品上保持一致以客戶為中心的一致性模型條件較弱只保持每個客戶端的一致性Outline39EventualConsistencyModelssuchassequentialconsistencyweredevelopedinthecontextofparallelprogramsrunningontightlycoupledshared-memorymultiprocessorswithpossiblymanyconcurrentreaders/writers;suchmodelsarenotwellsuitedfordistributedsystemswithsignificantinterprocessorcommunicationdelaysIndistributedsystems,muchweakerformsofconsistency,withmorerestrictiveusepatternsoftheshareddatastoreareoftenacceptable,e.g.,Onlyafew(orevenone)possiblewritersofdata,and/orRead-mostlydata(seldommodified),and/orStaledatamaybeacceptable(e.g.,web)EventualconsistencyIfnoupdatestakeplaceforalongtime,allreplicaswilleventuallybecomeconsistent40最終一致性在緊密耦合的共享存儲器多處理器(可能還有許多并發(fā)讀寫器)上運行的并行程序的上下文中開發(fā)了諸如順序一致性的模型;這種模型不太適合具有顯著的處理器間通信延遲的分布式系統(tǒng)在分布式系統(tǒng)中,共享數據存儲的更嚴格的使用模式的一致性較弱的形式通常是可接受的,例如,只有少數(甚至一個)可能的數據作者,和/或讀取主要數據(很少修改)和/或陳舊數據可能是可接受的(例如,網頁)最終一致性如果長時間不進行更新,所有副本將最終變得一致41EventualConsistencyMobileuserspresentachallengeClientmayaccessreplica1,makesomeupdatesClientmoves,accessesreplica2Modificationstoreplica1maynothavemigratedtoreplica2yet!42EventualConsistency移動用戶面臨挑戰(zhàn)客戶端可以訪問副本1,進行一些更新客戶端移動、訪問副本2對副本1的修改可能沒有遷移到副本243NotationNote:writesdonotnecessarilycompletelyoverwritedata(mayonlyupdatepartofthedata)xi[t]:versionofdataitemXatlocalcopyLiattimetWS(xi[t]):setofwriteoperationsonxatlocationLifrominitializationuntiltimetVariablexhastakenintoaccount(atleast)writesatLiuntiltimetWS(xi[t1];xj[t2]):setofwriteoperationsonxatlocationsLiuntiltimet1andLjuntiltimet2Variablexhastakenintoaccount(atleast)writesatLiuntiltimet1andwritesatLjuntilt2Here,inmostcasesomit“t”-clearbycontext44Notation注意:寫入不一定完全覆蓋數據(可能只更新部分數據)xi[t]:時間t為本地副本Li的數據項X的版本WS(xi[t]):從初始化到時間t,在位置Li處的x上的寫入操作的集合變數x考慮到(至少)在李直到時間t寫入WS(xi[t1];xj[t2]):在位置Li處的x到時間t1和時間t2之間的寫入操作集合變量x考慮到(至少)在Li直到時刻t1(至少)寫入到Lj直到t2在這里,大多數情況下省略“t”-通過上下文來清除45MonotonicReads(1)Adatastoreissaidtoprovidemonotonic-readconsistencyifthefollowingconditionholds:Ifaprocessreadsthevalueofadataitemx…anysuccessivereadoperationonxbythatprocesswillalwaysreturnthatsamevalueoramorerecentvalue.46單調讀(1)如果滿足以下條件,則數據存儲據稱提供單調讀取一致性:如果進程讀取數據項x的值...任何通過該進程對x進行的連續(xù)讀取操作將始終返回相同的值或更新的值。47MonotonicReads(2)ThereadoperationsperformedbyasingleprocessPattwodifferentlocalcopiesofthesamedatastore.
(a)Amonotonic-readconsistentdatastore.48MonotonicReads(2)在同一數據存儲的兩個不同本地副本上由單個進程P執(zhí)行的讀取操作。(a)單調讀取一致的數據存儲。49MonotonicReads(3)ThereadoperationsperformedbyasingleprocessPattwodifferentlocalcopiesofthesamedatastore.
(b)Adatastorethatdoesnotprovidemonotonicreads.50MonotonicReads(3)在同一數據存儲的兩個不同本地副本上由單個進程P執(zhí)行的讀取操作。(b)不提供單調讀數的數據存儲。51MonotonicWrites(1)Inamonotonic-writeconsistentstore,thefollowingconditionholds:Awriteoperationbyaprocessonadataitemx…iscompletedbeforeanysuccessivewriteoperationonxbythesameprocess.52MonotonicWrites(1)在單調寫入一致存儲中,以下條件成立:
對于數據項x上的進程的寫入操作在通過相同進程對x進行任何連續(xù)寫入操作之前完成。53MonotonicWrites(2)ThewriteoperationsperformedbyasingleprocessPattwodifferentlocalcopiesofthesamedatastore.(a)Amonotonic-writeconsistentdatastore.
54MonotonicWrites(3)ThewriteoperationsperformedbyasingleprocessPattwodifferentlocalcopiesofthesamedatastore.(b)Adatastorethatdoesnotprovidemonotonic-writeconsistency.55ReadYourWrites(1)Adatastoreissaidtoprovideread-your-writesconsistency,ifthefollowingc
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- T-ZNZ 264.1-2024 重金屬中度污染農田土壤修復和安全利用技術規(guī)范 第1部分:超積累東南景天與油葵輪作
- 二零二五年度車輛轉讓與二手車交易及金融服務協(xié)議
- 2025年度蛋糕店與體育賽事合作贊助協(xié)議
- 2025年度道路橋梁維修施工安全協(xié)議書
- 2025年度網絡安全產品銷售提成與技術服務合同
- 二零二五年度企業(yè)員工宿舍三方租賃協(xié)議
- 二零二五年度臨時廚房工作人員聘用合同
- 二零二五年度個體商戶勞動合同(體育賽事組織與運營)
- 中學生環(huán)保行動策劃案解讀
- 監(jiān)控項目合作合同監(jiān)控施工合同
- 2025年湖南鐵道職業(yè)技術學院單招職業(yè)技能測試題庫1套
- 學生創(chuàng)新能力培養(yǎng)方案計劃
- 《西門子PLC應用》一體化教案1-20周全篇
- 新蘇教版一年級科學下冊第一單元第1課《撿石頭》課件
- 2.2學會管理情緒 課件 -2024-2025學年統(tǒng)編版道德與法治七年級下冊
- 2025年湖北省技能高考(建筑技術類)《建筑材料與檢測》模擬練習試題庫(含答案)
- 2024-2025學年第二學期教學教研工作安排表 第二版
- 人行道道鋪設施工方案
- 2025年度模特代言合同隱私條款規(guī)范樣本4篇
- 【歷史】元朝的建立與統(tǒng)一課件 2024-2025學年統(tǒng)編版七年級歷史下冊
- 2025年度游戲工作室游戲客服中心用工合同
評論
0/150
提交評論