CIS 720 Lecture 5.

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.
Concurrent Programming Problems OS Spring Concurrency pros and cons Concurrency is good for users –One of the reasons for multiprogramming Working.
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.
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.
University of Pennsylvania 9/19/00CSE 3801 Concurrent Processes CSE 380 Lecture Note 4 Insup Lee.
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,
28/10/1999POS-A1 The Synchronization Problem Synchronization problems occur because –multiple processes or threads want to share data; –the executions.
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,
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.
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.
1 Critical Section Problem CIS 450 Winter 2003 Professor Jinhua Guo.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Software Verification 1 Deductive Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität und Fraunhofer Institut.
Model and complexity Many measures Space complexity Time complexity
Hwajung Lee ITEC452 Distributed Computing Lecture 8 Representing Distributed Algorithms.
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.
Lecture 2 Part 2 Process Synchronization
Practical Session 5, Synchronization
Mutual Exclusion CS p0 CS p1 p2 CS CS p3.
Group Mutual Exclusion & Hadzilacos Algorithm
Physical clock synchronization
ITEC452 Distributed Computing Lecture 7 Mutual Exclusion
CIS 720 Lecture 6.
COMP60621 Designing for Parallelism
CIS 720 Lecture 4.
CIS 720 Lecture 4.
CIS 720 Lecture 3.
CIS 720 Lecture 3.
CIS 720 Lecture 5.
CIS 720 Lecture 2.
CIS 720 Lecture 4.
CIS 720 Lecture 4.
CIS 720 Lecture 2.
CIS 720 Mutual Exclusion 2.
CIS 720 Lecture 4.
Don Porter Portions courtesy Emmett Witchel
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 Pi is of the form I /\ L, where L refers to local variables of Pi or to variables that only Pi 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} < await(B)  S > {Q}

b = false x = 0 ; y = 0; z = 0 co x = x + 1 b := true z = x + 3 // < await b  y = x > 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

Weak Fairness: A scheduling policy is weak fair if 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 CS1 CS2 do (true) do (true)  entry protocol; entry protocol; in1 = true in2 = true critical section critical section exit protocol; exit protocol; in1 = false in2 = false non-critical section non-critical section od

Invariant based approach CS1 CS2 do (true) do (true)  <await (!in2)  in1 = true> <await(!in1)  in2 = true> critical section critical section in1 = false in2 = false non-critical section non-critical section od

Invariant based approach CS1 CS2 do (true) do (true)  <await (!lock)  lock = true> <await(!lock)  lock = true> critical section critical section lock = false lock = false non-critical section non-critical section od

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

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