Model and complexity Many measures Space complexity Time complexity

Slides:



Advertisements
Similar presentations
Modeling issues Book: chapters 4.12, 5.4, 8.4, 10.1.
Advertisements

Mutual Exclusion – SW & HW By Oded Regev. Outline: Short review on the Bakery algorithm Short review on the Bakery algorithm Black & White Algorithm Black.
Models of Concurrency Manna, Pnueli.
Part 3: Safety and liveness
Program correctness The State-transition model A global state S  s 0 x s 1 x … x s m {s k = local state of process k} S0  S1  S2  … Each state transition.
Token-Dased DMX Algorithms n LeLann’s token ring n Suzuki-Kasami’s broadcast n Raymond’s tree.
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
Byzantine Generals Problem: Solution using signed messages.
June 10, 2015ICS102: while & do-while1 while and do-while Statements.
CPSC 668Set 3: Leader Election in Rings1 CPSC 668 Distributed Algorithms and Systems Spring 2008 Prof. Jennifer Welch.
CPSC 668Set 16: Distributed Shared Memory1 CPSC 668 Distributed Algorithms and Systems Fall 2006 Prof. Jennifer Welch.
Chapter 11: Distributed Processing Parallel programming Principles of parallel programming languages Concurrent execution –Programming constructs –Guarded.
Concurrency in Distributed Systems: Mutual exclusion.
© 2004 Pearson Addison-Wesley. All rights reserved5-1 Iterations/ Loops The while Statement Other Repetition Statements.
Fundamentals of Python: From First Programs Through Data Structures
Representing distributed algorithms Why do we need these? Don’t we already know a lot about programming? Well, you need to capture the notions of atomicity,
Why do we need models? There are many dimensions of variability in distributed systems. Examples: interprocess communication mechanisms, failure classes,
CS4231 Parallel and Distributed Algorithms AY 2006/2007 Semester 2 Lecture 10 Instructor: Haifeng YU.
PAGES:51-59 SECTION: CONTROL1 : DECISIONS Decisions.
Maekawa’s algorithm Divide the set of processes into subsets that satisfy the following two conditions: i  S i  i,j :  i,j  n-1 :: S i  S j.
THIRD PART Algorithms for Concurrent Distributed Systems: The Mutual Exclusion problem.
The Complexity of Distributed Algorithms. Common measures Space complexity How much space is needed per process to run an algorithm? (measured in terms.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 5: Introduction to C: More Control Flow.
Program correctness The State-transition model The set of global states = so x s1 x … x sm {sk is the set of local states of process k} S0 ---> S1 --->
Program correctness The State-transition model A global states S  s 0 x s 1 x … x s m {s k = set of local states of process k} S0  S1  S2  Each state.
Hwajung Lee. The State-transition model The set of global states = s 0 x s 1 x … x s m {s k is the set of local states of process k} S0  S1  S2  Each.
ITEC452 Distributed Computing Lecture 2 – Part 2 Models in Distributed Systems Hwajung Lee.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Mutual Exclusion & Leader Election Steve Ko Computer Sciences and Engineering University.
Hwajung Lee. The State-transition model The set of global states = s 0 x s 1 x … x s m {s k is the set of local states of process k} S0  S1  S2  Each.
Physical clock synchronization Question 1. Why is physical clock synchronization important? Question 2. With the price of atomic clocks or GPS coming down,
Hwajung Lee.  Models are simple abstractions that help understand the variability -- abstractions that preserve the essential features, but hide the.
Hwajung Lee. Well, you need to capture the notions of atomicity, non-determinism, fairness etc. These concepts are not built into languages like JAVA,
Hwajung Lee. Why do we need these? Don’t we already know a lot about programming? Well, you need to capture the notions of atomicity, non-determinism,
Hwajung Lee.  Models are simple abstractions that help understand the variability -- abstractions that preserve the essential features, but hide the.
1 Fault tolerance in distributed systems n Motivation n robust and stabilizing algorithms n failure models n robust algorithms u decision problems u impossibility.
Program Correctness. The designer of a distributed system has the responsibility of certifying the correctness of the system before users start using.
Presented by: Belgi Amir Seminar in Distributed Algorithms Designing correct concurrent algorithms Spring 2013.
Today’s Agenda  Quiz 4  Temporal Logic Formal Methods in Software Engineering1.
Hwajung Lee. Mutual Exclusion CS p0 p1 p2 p3 Some applications are:  Resource sharing  Avoiding concurrent update on shared data  Controlling the.
Agenda  Quick Review  Finish Introduction  Java Threads.
Introduction to distributed systems description relation to practice variables and communication primitives instructions states, actions and programs synchrony.
ITEC452 Distributed Computing Lecture 2 – Part 3 Models in Distributed Systems Hwajung Lee.
Sept COMP60611 Fundamentals of Parallel and Distributed Systems Lecture 8 Introduction to Modelling Concurrency John Gurd, Graham Riley Centre for.
Proof of liveness: an example
Chapter 5: Control Structures II
When Is Agreement Possible
Chapter 3 Loops Section 3.3 Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
Hwajung Lee ITEC452 Distributed Computing Lecture 8 Representing Distributed Algorithms.
LESSON 11 – WHILE LOOPS UNIT 5 – 1/10/17.
Control Structure Senior Lecturer
Outline Altering flow of control Boolean expressions
Alternating Bit Protocol
Atomicity, Non-determinism, Fairness
ITEC452 Distributed Computing Lecture 5 Program Correctness
Algorithm Discovery and Design
Outline Distributed Mutual Exclusion Introduction Performance measures
Mutual Exclusion CS p0 CS p1 p2 CS CS p3.
Three Special Structures – Case, Do While, and Do Until
Semaphores Chapter 6.
Distributed Transactions
Chapter8: Statement-Level Control Structures April 9, 2019
Physical clock synchronization
ITEC452 Distributed Computing Lecture 7 Mutual Exclusion
CIS 720 Lecture 5.
COMP60621 Designing for Parallelism
Introduction to verification
CIS 720 Lecture 5.
Distributed systems Consensus
Looping Structures.
ITEC452 Distributed Computing Lecture 3 Models in Distributed Systems
Presentation transcript:

Model and complexity Many measures Space complexity Time complexity Message complexity Bit complexity Round complexity Consider broadcasting in an n-cube (n=3) source

Broadcasting using messages {Process 0} sends m to neighbors {Process i > 0} repeat receive 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 m end if forever What is the (1) message complexity (2) space complexity per process? Each process j has a variable x[j] initially undefined

Broadcasting using shared memory {Process 0} x[0] := v {Process i > 0} repeat if  a neighbor j < i : x[i] ≠ x[j] then x[i] := x[j] {this is a step} else skip end if forever What is the time complexity? (i.e. no. of steps are needed?) Can be arbitrarily large! Each process j has a variable x[j] initially undefined

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) Each process j has a variable x[j] initially undefined

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? Each process j has a variable x[j] initially undefined

Representing distributed algorithms Why do we need these? Don’t we already know a lot about programming? Well, you need to capture the notions of atomicity, non-determinism, fairness etc. These concepts are not built into languages like JAVA, C++ etc!

Syntax & semantics: guarded actions <guard G>  <action A> is equivalent to if G then A

Syntax & semantics: guarded actions Sequential actions S0; S1; S2; . . . ; Sn Alternative constructs if . . . . . . . . . . fi Repetitive constructs do . . . . . . . . . od The specification is useful for representing abstract algorithms, not executable codes.

Syntax & semantics Alternative construct if G1  S1  G2  S2 …  Gn Sn fi When no guard is true, skip (do nothing). When multiple guards are true, the choice of the action to be executed is completely arbitrary.

Syntax & semantics do G1 S1  G2  S2 .  Gn  Sn od Repetitive construct do G1 S1  G2  S2 .  Gn  Sn od Keep executing the actions until all guards are false and the program terminates. When multiple guards are true, the choice of the action is arbitrary.

Example: graph coloring j  neighbor(i): c(j) = c(i)  c(i) := 1-c(i) 1 Will the computation terminate? 1

An example program uncertain; define x : integer; initially x = 0 do x < 4  x := x + 1  x = 3  x := 0 od Question. Will the program terminate? (Here fairness becomes an important issue)

The adversary A distributed computation can be viewed as a game between the system and an adversary. The adversary comes up with feasible schedules to challenge the system, and a correct algorithm must have an adequate response to meet the challenge.

Non-determinism Token server Non-determinism is abundant in the real world. Determinism is a special case of non-determinism. (Program for a token server - it has a single token} repeat if (req1 and token) then give the token to client1 else if (req2 and token) then give the token to client2 else if (req3 and token) then give the token to client3 forever Now, assume that all three requests are sent simultaneously. Client 1 always gets the token! Token server 3 1 2

Atomicity (or granularity) Atomic = all or nothing Atomic actions = indivisible actions do red  x:= 0 {red action}  blue  x:=7 {blue action} od Regardless of how nondeterminism is handled, we would expect that the value of x will be an arbitrary sequence of 0's and 7's. Right or wrong? x The answer depends on atomicity

Atomicity (or granularity) Does hardware guarantee any form of atomicity? Yes! Transactions are atomic by definition (in spite of process failures). Also, critical section codes are atomic. We will assume that G  A is an atomic operation if x ≠ y  y:= x fi x y if x ≠ y  y:= x fi

Atomicity {Program for P} define b: boolean initially b = true do b  send msg m to Q ¬ empty(R,P) receive msg; b := false od Suppose it takes 15 seconds to send the message. After 5 seconds, P receives a message from R. Will it stop sending the remainder of the message? NO. R P Q b

Fairness Defines the choices or restrictions on the scheduling of actions. No such restriction implies an unfair scheduler. For fair schedulers, the following types of fairness have received attention: Unconditional fairness Weak fairness Strong fairness

Fairness Program test define x : integer {initial value unknown} do true  x : = 0  x = 0  x : = 1  x = 1  x : = 2 od An unfair scheduler may never schedule the second (or the third actions). So, x may always be equal to zero. An unconditionally fair scheduler will eventually give every statement a chance to execute without checking their eligibility. (Example: process scheduler in a multiprogrammed OS.)

Weak fairness A scheduler is weakly fair, when it eventually executes every guarded action whose guard becomes true, and remains true thereafter A weakly fair scheduler will eventually execute the second action, but may never execute the third action. Why? Program test define x : integer {initial value unknown} do true  x : = 0  x = 0  x : = 1  x = 1  x : = 2 od

Strong fairness A scheduler is strongly fair, when it eventually executes every guarded action whose guard is true infinitely often. The third statement will be executed under a strongly fair scheduler. Why? Program test define x : integer {initial value unknown} do true  x : = 0  x = 0  x : = 1  x = 1  x : = 2 od