Docsity

Causal Order and Message Delivery in Parallel & Distributed Systems - Prof. Ingrid Hybinet, Study notes of Computer Science

Toggle sidebar
bg1
Maria Hybinette, UGA
CSCI 8220 Parallel & Distributed
Discrete Event Simulation
PDES: Message Order
Maria Hybinette, UGA 2
Event Order
!ā€œThingsā€ happen in the real world in a certain order (e.g., cause & effect).
!It should appear that events in the simulated world happen in the same
order as the real world actions that they represent.
Time (wallclock time)
Simulator A
(tank)
Simulator B
(target)
ā€œfireā€
ā€œtarget
destroyedā€
Simulator C
(observer)
event
message
simulated world
the observer should
see the tank fire
before the target is
destroyed.
real world
!Intuition: The observer could ā€œseeā€ the target is destroyed before the tank fired upon it!
!Temporal anomalies such as this may or may not be acceptable, depending on the federation’s goals
!Correct ordering of events can be achieved by assigning a time stamp (logical time) to each event, and
ensuring events are delivered in time stamp order (e.g., using conservative or optimistic
synchronization)
»This may entail significant computation/communication overheads
Maria Hybinette, UGA 3
Causal Order
!Defined for distributed computing in general
(not just simulation)
!Assumptions
»Set of processes; message-based communication
Ā»Each process’s execution a sequence of actions
–Local computation (event)
–Send message
–Deliver message to process
!Causal order defines an ordering among
actions/messages
Maria Hybinette, UGA 4
The ā€œHappens Beforeā€ Relationship
Definition (Lamport `78) ā€œhappens beforeā€ relationship ( ! ):
Consider two actions (event, send, or deliver), A1 and A2
!if A1 & A2 occur in the same process and A1 precedes A2 , then A1 ! A2
!if A1 is a send, and A2 is a delivery of the same message, then A1 ! A2
!if A1 ! A2 and A2 ! A3, then A1 ! A3 (transitivity)
Actions that are not causally related are said to be concurrent
Basic idea: If there is a left-to-right path from A1 to A2, then A1 ! A2
wallclock time
Federate A
Federate B
E1
E2
E1 ! E4
Federate C
E3E4
E1 ! E3
Maria Hybinette, UGA 5
Causal Order Message Delivery
Time (real-time)
Federate A
(tank 1)
Federate B
(tank 2)
Federate C
(observer)
fire event
destroyed
event ā€œdestroy messageā€ delayed
to preserve causal order
(fire is seen before destroyed)
Observation: Causal order message delivery avoids certain anomalies
that might occur in receive order delivery
Causally order does not consider application semantics - may impose an
ordering on independent events
!A message delivery service is said to be causally ordered if for any two
messages M1 and M2 sent to the same federate where M1 and M2 contain
notices for events E1 and E2, respectively, and E1 ! E2,
!then M1 is delivered to the federate before M2
!Messages for concurrent events may be delivered in any order
Maria Hybinette, UGA 6
Outline
!Causal Message Ordering
»Happens before relationship
»Causal order message delivery
!Causal Order Implementation
»Central message dispatcher
»Barriers
»Vector time stamps
!Limitations
pf3

Partial preview of the text

Download Causal Order and Message Delivery in Parallel & Distributed Systems - Prof. Ingrid Hybinet and more Study notes Computer Science in PDF only on Docsity!

Maria Hybinette, UGA

CSCI 8220 Parallel & Distributed

Discrete Event Simulation

PDES: Message Order

Maria Hybinette, UGA

Event Order

! ā€œThingsā€ happen in the real world in a certain order (e.g., cause & effect).

! It should appear that events in the simulated world happen in the same

order as the real world actions that they represent.

Time (wallclock time)

Simulator A

(tank)

Simulator B

(target)

ā€œfireā€

ā€œtarget

destroyedā€

Simulator C

(observer)

event

message

simulated world

the observer should

see the tank fire

before the target is

destroyed.

real world

! Intuition : The observer could ā€œseeā€ the target is destroyed before the tank fired upon it!

! Temporal anomalies such as this may or may not be acceptable, depending on the federation’s goals

! Correct ordering of events can be achieved by assigning a time stamp (logical time) to each event, and

ensuring events are delivered in time stamp order (e.g., using conservative or optimistic

synchronization)

Ā» This may entail significant computation/communication overheads

Maria Hybinette, UGA

Causal Order

! Defined for distributed computing in general

(not just simulation)

! Assumptions

Ā» Set of processes; message-based communication

Ā» Each process’s execution a sequence of actions

  • Local computation (event)
  • Send message
  • Deliver message to process

! Causal order defines an ordering among

actions/messages

Maria Hybinette, UGA

The ā€œHappens Beforeā€ Relationship

Definition (Lamport `78) ā€œhappens beforeā€ relationship (! ):

Consider two actions (event, send, or deliver), A1 and A

! if A1 & A2 occur in the same process and A1 precedes A2 , then A1! A

! if A1 is a send, and A2 is a delivery of the same message, then A1! A

! if A1! A2 and A2! A3, then A1! A3 (transitivity)

Actions that are not causally related are said to be concurrent

Basic idea: If there is a left-to-right path from A1 to A2, then A1! A

wallclock time

Federate A

Federate B

E 1

E 2

E

1

! E

4

Federate C

E 3

E 4

E

1

! E

3

Maria Hybinette, UGA

Causal Order Message Delivery

Time (real-time)

Federate A

(tank 1)

Federate B

(tank 2)

Federate C

(observer)

fire event

destroyed

event

ā€œdestroy messageā€ delayed

to preserve causal order

(fire is seen before destroyed)

Observation : Causal order message delivery avoids certain anomalies

that might occur in receive order delivery

Causally order does not consider application semantics - may impose an

ordering on independent events

! A message delivery service is said to be causally ordered if for any two

messages M1 and M2 sent to the same federate where M1 and M2 contain

notices for events E1 and E2, respectively, and E1! E2,

! then M1 is delivered to the federate before M

! Messages for concurrent events may be delivered in any order

Maria Hybinette, UGA

Outline

! Causal Message Ordering

Ā» Happens before relationship

Ā» Causal order message delivery

! Causal Order Implementation

Ā» Central message dispatcher

Ā» Barriers

Ā» Vector time stamps

! Limitations

Maria Hybinette, UGA

Central Dispatcher Implementation

! Assume reliable and ordered communication (e.g., TCP)

! Route all communications through a central message dispatcher

(within the RTI) that forwards message to its destination

Wallclock Time

Federate A

Federate B

Federate C

Dispatcher

Fire

Destroyed

Any event that depends on Fire event must be sent by the dispatcher

after it sends all messages for the Fire event, ensuring causal order

delivery

Maria Hybinette, UGA

Implementation Using Barriers

Assume reliable, ordered message delivery

Main loop in each simulator:

Wallclock Time

Federate A

Federate B

Federate C

Flush barrier

while( not done with simulation )

Deliver all events from RTI

Barrier

Process events, send messages

Flush barrier

Barrier serializes causally related events in different processors

Maria Hybinette, UGA

Vector Clocks

! Applicable to closed multicast group (sender is also a member

of the group)

! Process i maintains vector clock C

i

Ā» C

i

[i] = number of messages process i has sent to group

Ā» C

i [j] (j " i) = number of messages sent to group by process j that

have been delivered to process i (number of messages from j

causally preceding process i’s current event)

Ā» Example: C 1

  • Process 1 has sent 1 message
  • Process 1 has delivered 2 messages from process 2, 3 messages

from process 3, and 4 messages from process 4

! Attach a vector time stamp to each message; when process i

sends a message:

Ā» Increment C i

[i]

Ā» Use process i’s vector clock as message time stamp

Ā» Indicates which messages causally precede this message

Maria Hybinette, UGA

Message Delivery

Rules for message delivery

! A message M with time stamp T[ ] is sent by process S to

process R

! This message can be delivered to R when

Ā» T[S] = C

R

[S] + 1, and / check this is the next message from S /

Ā» T[j]! C R

[j], all j " S, / messages preceding M already delivered /

Ā» / If T[j] < C R [j], R has received other messages from process j /

[1,1,0]

[1,1,0]

[1,1,0]

[1,0,0]

[1,0,0]

[1,0,0]

P

P

P

[0,0,0]

[0,0,0]

[0,0,0]

Wallclock Time

Deliver?

[1,0,0]

Yes

Clock =

Time stamp?

Deliver? No!

[2,0,0]

[2,0,0]

[2,0,0]

Deliver? Yes

[2,1,0]

Deliver?

Yes [1,0,0]

Deliver

[1,1,0]

Deliver [2,1,0]

Deliver

[2,1,0]

Maria Hybinette, UGA

Outline

! Causal Message Ordering

Ā» Happens before relationship

Ā» Causal order message delivery

! Causal Order Implementation

Ā» Central message dispatcher

Ā» Barriers

Ā» Vector time stamps

! Limitations

Maria Hybinette, UGA

Causal and Totally Ordered

! pilot 1 has orders to attack the first enemy aircraft to take off; pilot

2 has orders to attack the second

! both pilots attack enemy aircraft

Time (real-time)

Federate A

(enemy aircraft 1)

Federate B

(enemy aircraft 2)

Federate C

(pilot 1)

attack aircraft 2

take off first

Federate D

(pilot 2)

take off second

attack aircraft 2

Observation: causal order allows different federates to receive

messages for concurrent events in different orders

Causal and totally ordered: all federates receiving messages for the

same events receive them in the same order.