T-79.4001 Seminar on Theoretical Computer Science Spring 2007 – Distributed Computation
Constructing a spanning tree
Toni Kylmälä
toni.kylmala@tkk.fi
1
Constructing a spanning tree Toni Kylml toni.kylmala@tkk.fi 1 - - PowerPoint PPT Presentation
T-79.4001 Seminar on Theoretical Computer Science Spring 2007 Distributed Computation Constructing a spanning tree Toni Kylml toni.kylmala@tkk.fi 1 Constructing a spanning tree Spanning tree To construct a spanning tree we must get
T-79.4001 Seminar on Theoretical Computer Science Spring 2007 – Distributed Computation
toni.kylmala@tkk.fi
1
Constructing a spanning tree
2
Constructing a spanning tree
3
PROTOCOL Shout Status: S = {INITIATOR, IDLE, ACTIVE, DONE} SINIT = {INITIATOR, IDLE} STERM = {DONE} Restrictions: R;UI; INITIATOR Spontaneuosly begin root := true Tree-neighbours := / send(Q)toN(x) counter := 0 becomeACTIVE end IDLE Receiving (Q) begin root := false parent := sender Tree−neighbours := {sender} send(Yes)to{sender} counter := 1 ifcounter = |N(x)|then becomeDONE else send(Q)toN(x)−{Sender} becomeACTIVE endif end ACTIVE Receiving (Q) begin send(No)to{sender} end Receiving (Yes) begin Tree−neighbours := Tree−neighboursS{sender} counter := counter + 1 if counter=|N(x)| then become DONE endif end Receiving (No) begin counter := counter + 1 if counter=|N(x)| then become DONE endif end
4
Constructing a spanning tree
5
Constructing a spanning tree
6
Constructing a spanning tree
7
Constructing a spanning tree
8
Constructing a spanning tree
9
Constructing a spanning tree
10
Constructing a spanning tree
11
Constructing a spanning tree
12
Constructing a spanning tree
13
Constructing a spanning tree
14
Constructing a spanning tree
15
Constructing a spanning tree
16
PROTOCOL MultiShout Status: S = {IDLE, ACTIVE, DONE} SINIT = {IDLE} STERM = {DONE} Restrictions: R;ID; IDLE Spontaneously begin root := true root_id := v(x) Tree-neighbours := / send(Q,root_id)toN(x) counter := 0 check_counter := 0 becomeACTIVE end Receiving(Q,id) begin CONSTRUCT end 17
ACTIVE Receiving(Q,id) begin if root_id = id then counter := counter + 1 if counter=|N(x)| then done := true CHECK endif else if root_id > id then CONSTRUCT endif end Receiving(Yes, id) begin if root_id = id then Tree-neighbours := Tree-neighboursS{sender} counter := counter + 1 if counter=|N(x)| then done := true CHECK endif endif end Receiving(Check, id) begin if root_id = id then check_counter := check_counter + 1 if (done ∧ check_counter=|Children|) then TERM endif endif end Receiving(Terminate) begin send(Terminate) to Children become DONE end Procedure CONSTRUCT begin root := false root_id := id Tree-neighbours := {sender} parent := sender send (Yes,root_id) to {sender} counter := 1 check_counter = 0 if counter = |N(x)| then done := true CHECK else send(Q,root_id) to N(x) - {sender} endif become ACTIVE end Procedure CHECK begin Children := Tree-neighbours - {parent} if Children = / 0 then send (Check,root_id) to parent endif end Procedure TERM begin if root then send(Terminate) to Tree-neighbours become DONE else send(Check,root_id) to parent endif end 18