ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

27
ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee

Transcript of ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

Page 1: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

ITEC452Distributed Computing

Lecture 2 – Part 2Models in Distributed Systems

Hwajung Lee

Page 2: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

3.5 Relationship among Models

Page 3: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

Weak vs. Strong Models

One object (or operation) of a strong model = More than one objects (or operations) of a weaker model.

Often, weaker models are synonymous with fewer restrictions.

One can add layers (additional restrictions) to create a stronger model from weaker one.

ExamplesHLL model is stronger

than assembly language model.

Asynchronous is weaker than synchronous.

Bounded delay is stronger than unbounded delay (channel)

Page 4: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

Model transformation

Stronger models - simplify reasoning, but - needs extra work to

implement

Weaker models - are easier to implement. - Have a closer

relationship with the real world

“Can model X be implemented using model Y?” is an interesting question in computer science.

Sample problemsNon-FIFO to FIFO channelMessage passing to

shared memoryNon-atomic broadcast to

atomic broadcast

Com

plica

ted

Sim

ple

Page 5: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

Non-FIFO to FIFO channel (1)

P Q

buffer

m1m4m3m2

Page 6: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

Non-FIFO to FIFO channel (2)

{Sender process P} {Receiver process Q}var i : integer {initially 0} var k : integer {initially 0}

buffer: buffer[0..∞] of msg {initially k: buffer [k] = empty

repeat repeat {STORE} send m[i],i to Q; receive m[i],i from P; i := i+1 store m[i] into buffer[i];

forever {DELIVER} while buffer[k] ≠ empty do

begin deliver content of buffer [k]; buffer [k] := empty k := k+1; endforever

Page 7: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

Observations(a) Needs Unbounded sequence numbers and (b) Unbounded number of buffer slots (Both are bad)

Now solve the same problem on a model where (a) The propagation delay has a known upper bound of T.(b) The messages are sent out @r per unit time.(c) The messages are received at a rate faster than r.

The buffer requirement drops to r.T. Synchrony pays.

Question. How to solve the problem using bounded buffer space if the propagation delay is arbitrarily large?

Page 8: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

Message-passing to Shared memory

{Read X by process i}: read x[i]

{Write X:= v by process i}- x[i] := v;- Atomically broadcast v to

every other process j (j ≠ i);- After receiving broadcast,

process j (j ≠ i) sets x[j] to v.

Understand the significance of atomic operations. It is not trivial, but is very important in distributed systems

0 1 2 3

X

processes

memory

x[0]

x[1]

x[2]

x[3]

(a) (b)

This is incomplete. There aremore pitfalls here.

Page 9: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

Non-atomic to atomic broadcast

Atomic broadcast = either everybody or nobody receives

{process i is the sender}for j = 1 to N-1 (j ≠ i) send message m to neighbor[j] (Easy!)

Now include crash failure as a part of our model. What if the sender crashes at the middle? Implement atomic broadcast in presence of crash.

Page 10: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

Mobile-agent based communication

Communicates via messengers instead of (or in addition to) messages.

What isthe lowestPrice of aniPod in Radford?

Carries bothprogram and data

Page 11: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

3.6 Classification Based on Special Properties

Page 12: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

Other classifications of models

Reactive vs Transformational systemsA reactive system never sleeps (like: a server)A transformational (or non-reactive systems) reaches a

fixed point after which no further change occurs in the system (Examples?)

Named vs Anonymous systemsIn named systems, process id is a part of the algorithm. In anonymous systems, it is not so. All are equal.

(-) Symmetry breaking is often a challenge.(+) Easy to switch one process by another with no side effect.

Saves log N bits.

Page 13: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

Knowledge based communication

Alice and Bob enter into an agreement:

whenever one falls sick, (s)he will call the other

person. Since making the agreement, no one

called the other person, so both concluded that

they are in good health. Assume that the clocks

are synchronized, communication links are

perfect, and a telephone call requires zero time

to reach. What kind of interprocess

communication model is this?

Page 14: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

History

The paper “Cheating Husbands and Other Stories: A

Case Study of Knowledge, Action, and

Communication” by Yoram Moses, danny Dolev,

Joseph Halpern illustrates how actions are taken and

decisions are made without explicit communication

using common knowledge.

(Adaptation of Gamow and Stern, “Forty unfaithful

wives,” Puzzle Math, 1958)

Page 15: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

Relevance

(Bidding in the game of cards like

bridge is an example of knowledge-

based communication)

Communicating through silence is

energy-efficient

Page 16: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

The Queen’s Proclamation The Queen read out the following in a meeting at the town

square.

There are one or more unfaithful husbands in our

community.

None of you know whether your husband is faithful. But

each of you which of the other husbands are unfaithful.

Do not discuss this with anyone, but should you discover

that your own husband is unfaithful, you should shoot him

on the midnight of the day you find out about it

Page 17: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

What happened after this

Thirty nine silent nights went by, and on

the fortieth night, gunshots were heard.

What was going on for 39 nights?

How many unfaithful husbands were there?

Why did it take so long

Page 18: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

A simple case

W2 does not know of any other unfaithful husband.

W2 knows that there is at least one (common knowledge)

W2 concludes that it must be H2, and kills him on the first night.

W1 H1

W2 H2

W3 H3

W4 H4

Page 19: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

Theorem

If there are N unfaithful H’s, then they will all be killed on the midnight of the Nth day.

Page 20: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

A more complicated case

W2 knows H3 is unfaithful.

She expects H3 to be killed

on the first night.

W3 has similar thoughts. So

no one was killed on the

first night.

W1 H1

W2 H2

W3 H3

W4 H4

Page 21: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

The case continues

Then W2 thinks, why wasn’t H3 killed in the first night. Does it mean, W3 knows of another unfaithful husband whom I don’t know? It must be my husband H2 then!

W3 has similar thoughts.

So both H2 and H3 are killed on the SECOND night.

W1 H1

W2 H2

W3 H3

W4 H4

Page 22: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

Common Knowledge

F is a common knowledge means:

Everyone knows FEveryone knows that everyone

knows FEveryone knows that everyone

knows that everyone knowsthat …F (ad infinitum) …

Page 23: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

Model and complexity

Many measures

o Space complexityo Time complexityo Message

complexityo Bit complexityo Round complexity

What do these mean?

Consider broadcasting in an n-cube (n=3)

0 1

2 3

45

6 7

source

Page 24: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

Broadcasting using messages

{Process 0} sends m to neighbors

{Process i > 0}repeatreceive m {m contains the value};if m is received for the first time then x[i] := m.value; send x[i] to each neighbor j > I else discard mend ifforever

What is the (1) message complexity(2) space complexity per process?

0 1

2 3

45

6 7

Each process jhas a variable x[j]initially undefined

Page 25: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

Broadcasting using shared memory

{Process 0} x[0] := v{Process i > 0}repeatif a neighbor j < i : x[i] ≠ x[j] then x[i] :=

x[j] {this is a step}

else skip end ifforever

What is the time complexity?(i.e. how many steps are needed?)Can be arbitrarily large! WHY?

0 1

2 3

45

6 7

Each process jhas a variable x[j]initially undefined

Page 26: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

Broadcasting using shared memory

Now, use “large atomicity”, where

in one step, a process j reads

the states of ALL its neighbors of

smaller id, and updates x[j] only

when these are equal, and

different from x[j].

What is the time complexity?

How many steps are needed?

The time complexity is now O(n2) 0 1

2 3

45

6 7

Each process jhas a variable x[j]initially undefined

Page 27: ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.

Time complexity in rounds

Rounds are truly defined for synchronous systems. An asynchronous round consists of a number of steps where every process (including the slowest one) takes at least one step. How many rounds will you need to complete the broadcast using the large atomicity model?

0 1

2 3

45

6 7

Each process jhas a variable x[j]initially undefined