CIS 720 Lecture 5. Techniques to avoid interference Disjoint variables –If the write set of each process is disjoint from the read and write set of other.

Slides:



Advertisements
Similar presentations
1 Interprocess Communication 1. Ways of passing information 2. Guarded critical activities (e.g. updating shared data) 3. Proper sequencing in case of.
Advertisements

CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Part 3: Safety and liveness
CIS 720 Lecture 2. Concurrency …shared variable declaration…. …shared variable initialization… co P 1 // P 2 // P 3 // P 4 oc Execution of P 1 … P 4 starts.
CSC321 Concurrent Programming: §3 The Mutual Exclusion Problem 1 Section 3 The Mutual Exclusion Problem.
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.
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
Silberschatz, Galvin and Gagne ©2007 Operating System Concepts with Java – 7 th Edition, Nov 15, 2006 Chapter 6 (a): Synchronization.
1 Chapter 2 Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2007 Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld.
5.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 5: CPU Scheduling.
Multiprocessor Synchronization Algorithms ( ) Lecturer: Danny Hendler The Mutual Exclusion problem.
Operating System Concepts and Techniques Lecture 12 Interprocess communication-1 M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and.
1 Operating Systems, 122 Practical Session 5, Synchronization 1.
Critical Section chapter3.
Multithreaded Programming ECEN5043 Software Engineering of Multiprogram Systems University of Colorado Lectures 5 & 6.
Sept COMP60611 Fundamentals of Parallel and Distributed Systems Lecture 12 The Critical Section problem John Gurd, Graham Riley Centre for Novel.
Chapter 3 The Critical Section Problem
CIS 720 Mutual Exclusion. Critical Section problem Process i do (true) entry protocol; critical section; exit protocol; non-critical section od.
Parallel Processing (CS526) Spring 2012(Week 6).  A parallel algorithm is a group of partitioned tasks that work with each other to solve a large problem.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Race Conditions Critical Sections Deker’s Algorithm.
University of Pennsylvania 9/19/00CSE 3801 Concurrent Processes CSE 380 Lecture Note 4 Insup Lee.
Chair of Software Engineering Concurrent Object-Oriented Programming Prof. Dr. Bertrand Meyer Exercise Session 2: Introduction.
1 Sharing Objects – Ch. 3 Visibility What is the source of the issue? Volatile Dekker’s algorithm Publication and Escape Thread Confinement Immutability.
Synchronization (other solutions …). Announcements Assignment 2 is graded Project 1 is due today.
1 Thread Synchronization: Too Much Milk. 2 Implementing Critical Sections in Software Hard The following example will demonstrate the difficulty of providing.
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,
The Critical Section Problem
28/10/1999POS-A1 The Synchronization Problem Synchronization problems occur because –multiple processes or threads want to share data; –the executions.
Sept COMP60611 Fundamentals of Parallel and Distributed Systems Lecture 15 More Advanced Program Properties: Temporal logic and jSpin John Gurd,
Concurrency. A process is a program executing on a virtual computer Processor speed and multiplexing of shared resources are ignored Order of thread execution.
The Complexity of Distributed Algorithms. Common measures Space complexity How much space is needed per process to run an algorithm? (measured in terms.
Mutual Exclusion Using Atomic Registers Lecturer: Netanel Dahan Instructor: Prof. Yehuda Afek B.Sc. Seminar on Distributed Computation Tel-Aviv University.
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.
Operating Systems CMPSC 473 Mutual Exclusion Lecture 11: October 5, 2010 Instructor: Bhuvan Urgaonkar.
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.
CIS 720 Correctness of Concurrent Programs. i := 1 max := A[1] do i < n  i = i + 1 if (max < A[i]) max = A[i] od.
1 Lecture 8: Concurrency: Mutual Exclusion and Synchronization Advanced Operating System Fall 2012.
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,
Program Correctness. The designer of a distributed system has the responsibility of certifying the correctness of the system before users start using.
1 Fundamentals of Concurrent Systems  Fundamentals of Concurrent Processes The issues to be addressed here are:  1. Process and Thread  2. Fine-Grained.
Presented by: Belgi Amir Seminar in Distributed Algorithms Designing correct concurrent algorithms Spring 2013.
CIS 725 Lecture 2. Finite State Machine Model FSM = (A, S, T, s 0 ) A = set of actions S = set of states s 0 = initial states T = transition relation.
1 Critical Section Problem CIS 450 Winter 2003 Professor Jinhua Guo.
Proving Correctness and Measuring Performance CET306 Harry R. Erwin University of Sunderland.
Hwajung Lee. Mutual Exclusion CS p0 p1 p2 p3 Some applications are:  Resource sharing  Avoiding concurrent update on shared data  Controlling the.
Introduction to distributed systems description relation to practice variables and communication primitives instructions states, actions and programs synchrony.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Model and complexity Many measures Space complexity Time complexity
What I Teach (Do what I say, not what I do)
Designing Parallel Algorithms (Synchronization)
Atomicity, Non-determinism, Fairness
ITEC452 Distributed Computing Lecture 5 Program Correctness
CIS 720 Mutual Exclusion 2.
Mutual Exclusion CS p0 CS p1 p2 CS CS p3.
CIS 720 Lecture 5.
CIS 720 Lecture 4.
CIS 720 Lecture 4.
CIS 720 Lecture 3.
CIS 720 Lecture 3.
CIS 720 Lecture 5.
CIS 720 Lecture 4.
CIS 720 Lecture 4.
CSE 542: Operating Systems
CIS 720 Mutual Exclusion 2.
CIS 720 Lecture 4.
Presentation transcript:

CIS 720 Lecture 5

Techniques to avoid interference Disjoint variables –If the write set of each process is disjoint from the read and write set of other processes, then the proof outlines will be interference free.

Avoiding interference Weakened assertions x= 0; co x = x + 1 // x = x + 2 od

Avoiding interference Global Invariants: Assume that every assertion in the proof outline of P i is of the form I /\ L, where L refers to local variables of P i or to variables that only P i writes. - Then the proof outlines will be interference free.

x = 0 ; y = 0; z = 0 co x = 1 y := 1 // if y = 1  z = 1 oc

Avoiding interference Synchronization Await Statement rule {P /\ B } S {Q} {P} {Q}

b = false x = 0 ; y = 0; z = 0 co x = x + 1 b := true z = x + 3 // oc

Bank transactions total = 0; i = 0; co // Transfer(x,y,am): Auditor: < await( (i < x /\ i < y) \/ {A1: Total = ac[0]+….+ac[i-1] } (i > x /\ i > y)) do i < n  ac[x] = ac[x] – am; i = i + 1 ac[y] = ac[y] + am > total = total + ac[i] od oc

Safety and liveness properties A safety property states that something bad will not happen A liveness property states that something good will eventually happen

Proving safety property BAD= predicate characterizing the bad property GOOD = not BAD Prove that GOOD is an invariant

Liveness property A statement is eligible if it is the next action that could be executed Scheduling policy determines the next statement to be executed

Unconditional fairness: A scheduling policy is unconditionally fair if every unconditional atomic action (one which does not have a guard) that is eligible is executed eventually. Weak Fairness: A scheduling policy is weak fair if –It is unconditionally fair –Every conditional action that is eligible is eventually executed assuming that its guard becomes true and remains true.

Strong Fairness: A scheduling policy is strong fair if –It is unconditionally fair –Every conditional action that is eligible is eventually executed assuming that its guard becomes true and becomes true infinitely often

Critical Section problem Process i do (true) entry protocol; critical section; exit protocol; non-critical section od

Correctness Mutual exclusion: at most one process at a time is executing its critical section Absence of deadlock: If two or more processes are trying to enter their critical section, at least one will succeed Absence of unnecessary delay: If a process is trying to enter its critical section and the other processes are executing their non-critical sections or have terminated then the first process is not prevented from entering its critical section. Eventual entry: A process that is attempting to enter its critical section will eventually succeed.

Invariant based approach CS1CS2 do (true)  entry protocol; in1 = truein2 = true critical section critical section exit protocol; in1 = falsein2 = false non-critical sectionnon-critical section od

Invariant based approach CS1CS2 do (true)  critical section critical section in1 = falsein2 = false non-critical sectionnon-critical section od

Invariant based approach CS1CS2 do (true)  critical section critical section lock = falselock = false non-critical sectionnon-critical section od

Test and set instruction CS1CS2 do (true)  while (TS(lock)) skip;while(TS(lock)); critical section critical section lock = falselock = false non-critical sectionnon-critical section od

Implementing await statements CSenter while (!B) { CSexit; CSenter } S; CSexit