Solutions of a Problem in Concurrent Programming - Yang Le 1 Solutions of a Problem in Concurrent Programming Proseminar Software Pioneers By Prof. Dr.

Slides:



Advertisements
Similar presentations
Symmetric Multiprocessors: Synchronization and Sequential Consistency.
Advertisements

Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
Chapter 6: Process Synchronization
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
1 Course Syllabus 1. Introduction - History; Views; Concepts; Structure 2. Process Management - Processes; State + Resources; Threads; Unix implementation.
THIRD PART Algorithms for Concurrent Distributed Systems: The Mutual Exclusion problem.
CPSC 668Set 7: Mutual Exclusion with Read/Write Variables1 CPSC 668 Distributed Algorithms and Systems Fall 2009 Prof. Jennifer Welch.
Multiprocess Synchronization Algorithms ( )
The Critical-Section Problem
1 Course Syllabus 1. Introduction - History; Views; Concepts; Structure 2. Process Management - Processes; State + Resources; Threads; Unix implementation.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts Amherst Operating Systems CMPSCI 377 Lecture.
1 Tuesday, June 20, 2006 "The box said that I needed to have Windows 98 or better... so I installed Linux." - LinuxNewbie.org.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 7: Process Synchronization Background The Critical-Section Problem Synchronization.
6/16/2015 Chapter Eight Process Synchronisation. Index Objectives Concurrent processes and Asynchronous concurrent processes Process synchronisation Mutual.
OS Spring’04 Concurrency Operating Systems Spring 2004.
Bakery Algorithm - Proof
Concurrency in Distributed Systems: Mutual exclusion.
CIS 415 Process Synchronization Background The Critical-Section Problem Software Solutions Semaphores Hardware Support Classical Problems of Synchronization.
1 Chapter 6: Concurrency: Mutual Exclusion and Synchronization Operating System Spring 2007 Chapter 6 of textbook.
1 Lecture 9: Synchronization  concurrency examples and the need for synchronization  definition of mutual exclusion (MX)  programming solutions for.
Chapter 6 Process Synchronization Copyright © 2008.
Semaphores and Bounded Buffer Andy Wang Operating Systems COP 4610 / CGS 5765.
The Critical Section Problem
Understanding Operating Systems 1 Chapter 6 : Concurrent Processes What is Parallel Processing? Typical Multiprocessing Configurations Process Synchronization.
Process Synchronization Continued 7.2 Critical-Section Problem 7.3 Synchronization Hardware 7.4 Semaphores.
6.3 Peterson’s Solution The two processes share two variables: Int turn; Boolean flag[2] The variable turn indicates whose turn it is to enter the critical.
THIRD PART Algorithms for Concurrent Distributed Systems: The Mutual Exclusion problem.
3.1. Concurrency, Critical Sections, Semaphores
Mutual Exclusion Using Atomic Registers Lecturer: Netanel Dahan Instructor: Prof. Yehuda Afek B.Sc. Seminar on Distributed Computation Tel-Aviv University.
1 Chapter 2 Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2014 Synchronization Algorithms and Concurrent Programming Synchronization.
Process Synchronization Tanenbaum Ch 2.3, 2.5 Silberschatz Ch 6.
1 Concurrent Processes. 2 Cooperating Processes  Operating systems allow for the creation and concurrent execution of multiple processes  concurrency.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Lecture 11: Synchronization (Chapter 6, cont)
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-5 Process Synchronization Department of Computer Science and Software.
CS533 Concepts of Operating Systems Jonathan Walpole.
Lecture 6 Page 1 CS 111 Summer 2013 Concurrency Solutions and Deadlock CS 111 Operating Systems Peter Reiher.
Implementing Lock. From the Previous Lecture  The “too much milk” example shows that writing concurrent programs directly with load and store instructions.
6.852: Distributed Algorithms Spring, 2008 Class 14.
The Structure of the "THE"- Multiprogramming Edsger W. Dijkstra Technological University, Eindhoven, The Netherlands System Andrew Edwards.
OS Winter’03 Concurrency. OS Winter’03 Bakery algorithm of Lamport  Critical section algorithm for any n>1  Each time a process is requesting an entry.
Symmetric Multiprocessors: Synchronization and Sequential Consistency
Bakery Algorithm - Proof
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS
“Language Mechanism for Synchronization”
Chapter 6-7: Process Synchronization
The Critical-Section Problem (Two-Process Solution)
Concurrent Distributed Systems
Threading And Parallel Programming Constructs
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS
Lecture 22 Syed Mansoor Sarwar
The Critical-Section Problem
Module 7a: Classic Synchronization
Course Syllabus 1. Introduction - History; Views; Concepts; Structure
Lecture 20 Syed Mansoor Sarwar
Lecture 2 Part 2 Process Synchronization
Implementing Mutual Exclusion
Concurrency: Mutual Exclusion and Process Synchronization
Course Syllabus 1. Introduction - History; Views; Concepts; Structure
Implementing Mutual Exclusion
Multiprocessor Synchronization Algorithms ( )
Lecture 21 Syed Mansoor Sarwar
Course Syllabus 1. Introduction - History; Views; Concepts; Structure
CSE 153 Design of Operating Systems Winter 19
Course Syllabus 1. Introduction - History; Views; Concepts; Structure
Process Synchronization
Atomicity, Mutex, and Locks
Course Syllabus 1. Introduction - History; Views; Concepts; Structure
Process Synchronization
Steve’s Concurrency Slides
Syllabus 1. Introduction - History; Views; Concepts; Structure
Presentation transcript:

Solutions of a Problem in Concurrent Programming - Yang Le 1 Solutions of a Problem in Concurrent Programming Proseminar Software Pioneers By Prof. Dr. Heike Wehrheim Diplo. Inform. Björn Metzler

Solutions of a Problem in Concurrent Programming - Yang Le 2 Contents A brief introduction of Dijkstra and Lamport Problem in Concurrent Programming Dijkstra’s Solution Semaphores Solution Lamport’s Solution Conclusion

Solutions of a Problem in Concurrent Programming - Yang Le 3 Edsger W. Dijkstra and Leslie Lamport Photographs are from google photo

Solutions of a Problem in Concurrent Programming - Yang Le 4 Problem in Concurrent Programming N computers one “critical section”. Two requirements: Communication between computers Undividable writing or reading Critical Section N

Solutions of a Problem in Concurrent Programming - Yang Le 5 Basic Goals of Dijkstra’s Solution Symmetric between N computers No “After you” – “After you” – blocking i Please, you can go first. j No, no. I will wait after you.

Solutions of a Problem in Concurrent Programming - Yang Le 6 Dijkstra’s Solution Code from “Solution of a Problem in Concurrent Programming Control” – E.W.Dijkstra Part I: Interger j; Li0:b[i]:=false; Li1:if k≠i then Li2: begin c[i]:=true; Li3: if b[k] then k:=i; goto Li1; end else. 123N Critical Section i 123iNk b[i]TTTFT c[i]TTTTTi

Solutions of a Problem in Concurrent Programming - Yang Le 7 Dijkstra’s Solution Part II: Li4:begin c[i]:=false; for j:=1 step 1 until N do if j≠i and not c[j] then goto Li1 end; critical section; c[i]:=true;b[i]:=true;. go to Li0 123N Critical Section i 123iNk b[i]TTTFT c[i]TTTFTi Code from “Solution of a Problem in Concurrent Programming Control” – E.W.Dijkstra

Solutions of a Problem in Concurrent Programming - Yang Le 8 Problems in Dijkstra’s Solution When the i-th computer breaks down in the critical section, the whole system will be in a dead lock 123N Critical Section i What is he doing for such a long time? Who knows. Just have to wait here. ??? ? Hey, we have waited too long!

Solutions of a Problem in Concurrent Programming - Yang Le 9 Semaphores Solution Semaphore values Two “indivisible actions” P- operation V- operation Random choosing from the waiting list begin semaphore mutex; mutex := 1; parbegin begin L1: P(mutex); critcal section 1; V(mutex); remainder of cycle 1; go to L1 end; begin L2: P(mutex); critical section 2; V(mutex); remainder of cycle 2; go to L2 end; parendend end

Solutions of a Problem in Concurrent Programming - Yang Le 10 Problems of Semaphores Solution We can no forecast or decide which process will be removed from the waiting list. Explicit control - deadlock What is he waiting for? And why make him the boss? i Don’t know. Just wait and see. j Semaphore ?????

Solutions of a Problem in Concurrent Programming - Yang Le 11 Lamport’s Solution Begin integer j; L1: choosing[i]:=1; number[i]:=1+maximum(number[1],...number[N]); choosing[i]:=0; for j:=1 step 1 until N do begin L2: if choosing[j]≠0 then goto L2; L3: if number[j]≠0 and (number[j],j)< (number[i],i) then goto L3; end Critical section; Number[i]:=0; Noncritical section; Goto L1; end Critical Section 123Ni 123iN Choosing[]00000 Number[]63425

Solutions of a Problem in Concurrent Programming - Yang Le 12 Lamport’s Solution Begin integer j; L1: choosing[i]:=1; number[i]:=1+maximum(number[1],...number[N]); choosing[i]:=0; for j:=1 step 1 until N do begin L2: if choosing[j]≠0 then goto L2; L3: if number[j]≠0 and (number[j],j)< (number[i],i) then goto L3; end Critical section; Number[i]:=0; Noncritical section; Goto L1; end Critical Section 123N i 123iN Choosing[]00000 Number[]63425

Solutions of a Problem in Concurrent Programming - Yang Le 13 Problems in Lamport’s Solution These computers are no longer symmetrical. The number attribute will be too big. Critical Section Let’s compare our “number” attribute, then decide who goes to first. i No, I can’t. This is too big to fit in a double integer. j

Solutions of a Problem in Concurrent Programming - Yang Le 14 Conclusion Dijkstra’s Solution N computers get equal chances, and avoid “after you” – “after you” – blocking. Weak point: Once one computer breaks down inside the CS, that will be a catastrophe. Semaphores Solution Based on a semaphore value with two undividable action – P and V. Weak point: Too reliance upon a single hardware component. Lamport’s Solution Every computer got its own attribute and don’t afraid “break-down” in CS. This attribute will be too huge and increase the system’s load.