Implementation:definition Implementation:correctness - - PDF document

implementation definition implementation correctness
SMART_READER_LITE
LIVE PREVIEW

Implementation:definition Implementation:correctness - - PDF document

Sofar 2processconsensuscannotbesolvedusing Consensus:partII registers Nprocessconsensuscanbesolveduisng registersand' 2processconsensuscanbesolvedusing


slide-1
SLIDE 1

1 Consensus:partII

FDC SummerTerm2007

MaxPlanckInstituteforSoftware Systems

  • Sofar…

2processconsensuscannotbesolvedusing

registers

Nprocessconsensuscanbesolveduisng

registersand'

2processconsensuscanbesolvedusing

registersandT&Sorqueues(butnot3 processconsensus) Whyconsensusisinteresting?

  • Becauseitisuniversal!

IfwecansolveconsensusamongN

processes,thenwecanimplement every

  • bjectsharedbyNprocesses

Akeytoimplementagenericfaulttolerant

service(replicatedstatemachine)

  • Whatisanobject?

ObjectOisdefinedbythetuple (Q,R,S,σ):

SetofstatesQ SetofoutputsR SetofoperationsS Sequentialspecificationσ,asubsetof

SxQxRxQ:

(o,q,r,q’)isinσ ifoperationoisappliedtoan

  • bjectinstateq,thentheobjectcan returnr

andchangeitsstatetoq’

  • Deterministicobjectsandbinding

Anoperationappliedtoadeterministic

  • bjectresultsinexactlyone(output,state)

inRxQ,i.e.,σ canbeseenafunctionSxQ > RxQ

Weassumethateveryprocesscanattach

itself toeveryobjectatanypointof comutation (softwired bindingmodel)

  • Implementinganobject

Usingonly base objects,animplementationofan

  • bjectO=(Q,R,S,σ)exportstheoperationsinSto

theprocessesandcreatesanillusionthatan atomic objectOisavailable

deq() x enq(x)

  • k

empty deq() Queue Base

  • bjects
slide-2
SLIDE 2

2

  • Implementation:definition

AdistributedalgorithmAthat,foreach

  • perationoinSandforeverypi,describes

thecorrespondingsequenceofstepsonthe baseobjects

ArunofAiswellformed ifnoprocessinvokesa newoperationontheimplementedobjectbefore returningfromtheoldone

  • Implementation:correctness

A(waitfree)implementationAiscorrectif ineverywellformedrunofA

everyoperationrunbypi

returnsinafinitenumberofstepsofpi

≈ operations“appear”

instantaneous(thecorrespondinghistory is strictlylinearizable)

Theformaldefinitionfollows

  • Histories

AhistoryofagivenrunofAisasequenceof invocationandresponsesontheimplemented

  • bjectinthatrun

E.g.,p1>Q.enqueue(x),p2>Q.dequeue(),p1>ok,p2>x,…

Ahistoryissequentialifeveryinvocationis followedbyacorrespondingresponse

E.g.,p1>Q.enqueue(x),p1>ok,p2>Q.dequeue(),p2>x,… (Asequentialhistoryhasnoconcurrentoperations)

  • Legalhistories

Asequentialhistoryislegal ifitsatisfiesthe sequentialspecificationoftheimplemented

  • bject

Example:LIFOqueues: Everydequeue()returnstheargumentof thelastenqueued element

  • Completeoperationsandcompletions

Anoperationopiscomplete inHifH containsinvocationandresponseofop Acompletion ofHisacompletehistoryH’ thatcontainsallcompleteoperationsofH andasubset ofincompleteoperationsofH completedwithmatching responses

  • Completeoperationsandcompletions

p1 p2 p3

  • !
slide-3
SLIDE 3

3

  • Completeoperationsandcompletions

p1 p2 p3

  • Strictlinearizability

AfinitehistoryHisstrictlylinearizable ifthere existsH’,alegalsequentialcompletionofH,that preservestheprecedencerelationofH:

  • p1precedesop2inH=>op1precedesop2inH’

(allcompleteoperationandasubsetofincomplete

  • perationscanbelinearized)

Animplementationisstrictlylinearizable ifevery finiterunofitproducesastrictlylinearizable history

  • Linearization

p1 p2 p3

  • Universalconstruction

"# [Herlihy,1991]IfNprocesses cansolveconsensus,thenNprocessescan (waitfree)implementeveryobject O=(Q,R,S,σ)

  • Universalconstruction:idea

Everyprocessthathasapendingoperation doesthefollowing:

Publishthecorrespondingrequest Collectpublishedrequestsanduse

consensusinstancestoserializethem:the processesagreeontheorderinwhichthe requestsareexecuted

  • Universalconstruction:variables

Sharedabstractions: NatomicregistersR[0,…,N1],initiallyØ NprocessconsensusinstancesC[1],C[2],… Localvariablesforeachprocesspi: integerseq,initially0 //thenumberofexecutedoperations integerk,initiaqlly 0 //thenumberoflinearized batchesof //requests sequencelinearized,initiallyempty //thesequenceoflinearized requests

slide-4
SLIDE 4

4

  • Universalconstruction:algorithm

Codeforeachprocesspi: Implementationofoperationop seq++ R[i]:=(op,i,seq) //publishtherequest repeat V:=readR[0,…,N1]//collectallrequests req :=V{linearized} //choosenotyetlinearized requests ifreq≠Ø then k++ decided:=C[k].propose(req) linearized :=linearized.decided //appenddecidedrequestinsomedeterministicorder until(op,i,seq)inlinearized returntheresultof(op,i,seq)inlinearized //usingσ

  • Universalconstruction:correctness

Linearizationofagivenrun:theorderin

whichoperationsareputinthelongest linearized list(welldefinedalllinearized listsarerelatedbycontainment)

Ineveryfiniterun,thelongestlinearized list consistsofallcompleteoperationsandasubset

  • fincompleteones
  • Universalconstruction:correctness

Waitfreedom:

Terminationandvalidityofconsensus:there existsksuchthattherequestofpigetsinto req listofeveryprocessesthatruns C[k].propose(req)

Strictlinearizability:ifop1precedesop2,

thenop2cannotbelinearized beforeop1

Validityofconsensus:avaluecannotbe decidedunlessitwaspreviouslyproposed

  • Anotheruniversalabstraction:CAS

Compare&Swap (CAS)storesavalue and exportsoperationCAS(u,v)suchthat:

Ifthecurrentvalueisu,CAS(u,v)replaces

itwithvandreturnsu

Otherwise,CAS(u,v)returnsthecurrent

value Avariation: CASreturnsaboolean (whether thereplacementtookplace)andan additionaloperationread()returnsthe value

  • NprocessconsensuswithCAS

Sharedobjects: CASCSinitializedØ //Ø cannotbeaninputvalue Codeforeachprocesspi(i=0,…,N1): vi:=inputvalueofpi v:=CS.CAS(vi) ifv=Ø returnvi else returnv

  • Nconsensusobject

Nconsensusstoresavaluein{Ø}UVand exportsoperationpropose(v),vinV: For1st toNth propose()operations:

IfthevalueisØ,thenpropose(v)setsthe

valuetovandreturnsv

Otherwise,returnsthevalue

Allotheroperationsdnotchangethevalue andreturnØ

slide-5
SLIDE 5

5

  • NprocessconsensuswithNconsensus

Immediate:everyprocesspisimplyinvokes C.propose(input ofpi)andreturnsthe resultofit (N+1)consensususingNconsensus?

  • Consensusnumber

AnobjectOhasconsensusnumberk(wewrite cons(O)=k)if

kprocessconsensuscanbesolvedusingregisters

andanynumberofcopiesofObut(k+1) consensuscannot IfnosuchnumberkexistsforO,thencons(O)=∞ (k=cons(O)isthemaximalnumberofprocessesthat canbesynchronizedusingcopiesofOand registers)

  • Consensusnumbers

cons(register)=1 cons(T&S)=cons(queue)=2 … cons(Nconsensus)=N

NconsensusisNuniversal!

… cons(CAS)=∞

  • Openquestions

Robustness

SupposewehavetwoobjectsAandB, cons(A)=cons(B)=k Canwesolve(k+1)consensususing registersandcopiesofAandB?

Canweimplementanobjectofconsensus

powerksharedbyNprocesses(N≥k)using kconsensusobjects?