CS 361 Concurrent programming Drexel University Fall 2004 Lecture 8. Proof by contradiction. Proof of correctness. Proof of mutual exclusion property
|
|
- Alban Golden
- 6 years ago
- Views:
Transcription
1 CS 361 Concurrent programming Drexel University Fall 2004 Lecture 8 Bruce Char and Vera Zaychik. All rights reserved by the author. Permission is given to students enrolled in CS361 Fall 2004 to reproduce these notes for their own use. Peterson s attempt (mutual exclusion for two threads) public void wanttoentercs(int I) { // preprotocol desirecs[i].value = true; last = other(i); while (desirecs[other(i)].value && last == other(i)) public void finishedincs(int I) { // postprotocol desirecs[i].value=false; page 1 page 2 Proof of correctness Prove that the algorithm enforces mutual exclusion correctly by showing that it is impossible for two threads to be in the critical section simultaneously. doesn t allow deadlock (i.e. it s impossible). doesn t allow starvation in the presence of contention doesn t allow starvation in the absence of contention A separate proof for each point, each done as a proof by contradiction. Proof by contradiction If you show that assuming p leads you to conclude something which you know to be false, then you are forced to conclude that there are no circumstances when p is true in other words, p must be false all the time. ( p p page 3 page 4 We talk about two threads running Peterson s algorithm. We assume that they violate ME (call this assumption v). We show that assuming v leads to the conditions that contradict the threads programming. In particular, we conclude s: that each thread set a variable last to different values. We know this violates the rules of programming languages, in other words: s=false. v Since we have shown v=>false, we conclude that the two threads cannot violate ME if they follow Peterson s algorithm. page 5 Game plan for proof by contradiction page 6 Proof of mutual exclusion property Some observations on Peterson s code: the only values that last can take on are 0 and 1. Each thread can enter its critical section only if!( desirecs.value[other(i)] && last == other(i)). That is, either desirecs.value[other(i)] is false or last = = i. Start of proof by contradiction: Assume that this algorithm does not support mutual exclusion. So there must be a scenario where both threads end up in the CS at once.
2 Proofs by contradiction when the world is divided into two cases Show each case separately: page 7 ( v ( v true ( v ( case1 case2) (( v case1) (( v case2) Proof of mutual exclusion, case 1 Suppose one thread (say, 0) gets through the preprotocol (evaluates the while condition) before the other thread has finished executing any lines of it (before it has set its value flag to true). It s then easy to see that the second thread will get stuck in the loop until the first thread does the postprotocol. This contradicts the assumption that both threads get into the CS at once. We get a similar contradiction if we assume that thread 1 gets in first and thread 0 lags. There are actually two subcases (case1a,case1b) we ve shown case1a and the proof for case1b is page 8 similar. What s false. ME violation Thread 0 gets into CS Thread 1 gets into CS Thread 0 gets into CS first Thread 1 does not get into CS An easy toprovefact: ( p q1 q2 r q2) false One case down, one to go We ve taken the assumption in case1 to prove something that we know is false. So we now need to prove that the assumptions in case2 also lead to false. Case 2 is not case 1 : a scenario where there is overlap in the preprotocol: one thread finishes at least the first instruction before the other thread begins execution of its last one. page 9 page 10 Case 2a: thread #0 ahead of #1 but both in preprotocol at once public void wanttoentercs(int I) { // preprotocol desirecs[i].value = true; (A) last = other(i); (B) while (desirecs[other(i)].value && last == other(i)) (C) We are assuming thread #1 has done A before #0 does C. So when thread #0 does C, last==0 (!=other(0)) or else thread #0 will loop instead of get into the CS. Thread #1 must have set last after Thread #0 set it. page 11 page 12 Case 2a, continued. When thread #1 checks its while loop condition, we know that desirecs[0].value is true because Thread #0 has already done it. So the only way that thread #1 can fall out of the while loop is if last=1. But we know that at that point when Thread #1 does this check, it has already done last=0. So it must be that Thread 0 has set last after Thread 1. We have deduced that if both threads get into the critical section, each must have set last last (to different values). This is false (based on what we know about the way programs and variables behave).
3 page 13 Proof of mutual exclusion (the conclusion) There is a case2b, where Thread #1 is ahead of Thread #0. We find a similar problem then. We assumed that the algorithm failed to provide mutual exclusion. From this we were led to two kinds cases: (overlap/no overlap of execution of the preprotocol). In both cases, we found that assuming that the algorithm allows violations of mutual exclusion leads to something we know is false (that both threads get into the CS while one is stuck in the pre-protocol, or that last has two values at the same time). page 14 Proof of mutual exclusion (the finale) We can conclude that it is impossible for the algorithm to violate mutual exclusion. Avoiding double negatives, another way of saying this is that the algorithm guarantees mutual exclusion: at most one thread is permitted into the critical section at a time. Proof of starvation in the absence of contention If thread 0 is not interested in entering its CS, then its flag is false and so thread 1 can enter because the while loop will not block it. Similar argument for thread 1. Proof for no starvation in the presence of contention We prove this by contradiction. Assume that thread 0 is frustrated while thread 1 tries and succeeds repeatedly. We will show that assuming this leads us to prove a statement we know is false. page 15 page 16 Proof in the presence of contention, con t If thread 0 has entered the preprotocol and has set desirecs[0] to true but is stuck it must be executing its while statement repeatedly. Thus desirecs[1] is true and last==0, at least while thread 0 is repeating. But this means that thread 1 will enter its critical section if it hasn t already Once it leaves its critical section, it will reset desirecs[1] to false. Proof in presence of contention, con t What can happen after thread 1 leaves its post protocol Either thread 1 whips around into its preprotocol and sets desirecs[1] to true again before thread 0 notices, or Or thread 0 notices that desirecs[1] is false before thread 1 tries to re-enter the preprotocol. It proceeds into the CS which again is a contradiction of our original assumption. page 17 page 18
4 What happens when thread 1 enters the preprotocol again After setting desirecs[1] to true again, thread 1 will then set last to 0. It will hang up in its loop. Thread 0 will wake up (because of the yield) and stop looping because its while condition is no longer true. It will proceed into the CS. This again contradicts our assumption that thread 0 was hopelessly stuck. Completed proof of no starvation in presence of contention Thus in all cases, assuming that thread 0 is stuck in its loop forever produces a contradiction. So it s impossible -- thread 0 must enter its CS after at most one entry by thread 1. page 19 page 20 Conclusion of proof of no starvation A similar argument can be made for thread 1 being stuck forever. We have to check this, but it really goes through by a mechanical substitution of 0 for 1 and vice versa in our original argument. These are all the possibilities for threads getting starved with contention. We end up with a contradiction in each case. No deadlock If both threads are stuck in the critical section, then they both must be looping. Once they are looping, neither can change the value of last or their desirecs values. For both to loop, both threads have set their desirecs values to true. For both to loop, last must be both 0 and 1 at the same time. This is impossible (violates the rules of programming) page 21 page 22 Peterson s attempt (Hartley s way) public void wanttoentercs(int i) { // preprotocol desirecs[i].value = true; last = i; while (desirecs[other(i)].value && last == i) public void finishedincs(int i) { // postprotocol desirecs[i].value=false; Peterson s attempt (problem 6 of book) public void wanttoentercs(int i) { // preprotocol last = i; desirecs[i].value = true; while (desirecs[other(i)].value && last == i) public void finishedincs(int I) { // postprotocol desirecs[i].value=false; page 23 page 24
5 Works for only two threads Note that if there are other threads doing other things, the yield() loop may not give control to the other thread dealing with this critical section. Have to hope that sooner or later the other contending thread gets a chance to do its preprotocol. page 25
Pre- and post- CS protocols. CS 361 Concurrent programming Drexel University Fall 2004 Lecture 7. Other requirements for a mutual exclusion algorithm
CS 361 Concurrent programming Drexel University Fall 2004 Lecture 7 Bruce Char and Vera Zaychik. All rights reserved by the author. Permission is given to students enrolled in CS361 Fall 2004 to reproduce
More informationMemory system behavior: volatile variables. CS 361 Concurrent programming Drexel University Fall 2004 Lecture 6. Volatile variables and concurrency
CS 361 Concurrent programming Dreel University Fall 2004 Lecture 6 Bruce Char and Vera Zaychik. All rights reserved by the author. Permission is given to students enrolled in CS361 Fall 2004 to reproduce
More informationMidterm on next week Tuesday May 4. CS 361 Concurrent programming Drexel University Fall 2004 Lecture 9
CS 361 Concurrent programming Drexel University Fall 2004 Lecture 9 Bruce Char and Vera Zaychik. All rights reserved by the author. Permission is given to students enrolled in CS361 Fall 2004 to reproduce
More informationCoSc 450: Programming Paradigms. The Critical Section Problem
CoSc 450: Programming Paradigms 03 The Critical Section Problem Algorithm 3.1: Critical section problem global variables p q local variables local variables loop forever loop forever non-critical section
More informationMutual Exclusion. 1 Formal problem definitions. Time notion CSE /17/2015. Outline of this lecture:
CSE 539 03/17/2015 Mutual Exclusion Lecture 15 Scribe: Son Dinh Outline of this lecture: 1. Formal problem definitions 2. Solution for 2 threads 3. Solution for n threads 4. Inherent costs of mutual exclusion
More informationPROVING THINGS ABOUT PROGRAMS
PROVING THINGS ABOUT CONCURRENT PROGRAMS Lecture 23 CS2110 Fall 2010 Overview 2 Last time we looked at techniques for proving things about recursive algorithms We saw that in general, recursion matches
More informationFall 2004 CS414 Prelim 1
Fall 2004 CS414 Prelim 1 1. The Sim City Smoking Ban problem: In the Sim-City community Woobish most people smoke, but the laws of Sim City require that non-smokers be protected from passive smoke. So
More information10/17/2011. Cooperating Processes. Synchronization 1. Example: Producer Consumer (3) Example
Cooperating Processes Synchronization 1 Chapter 6.1 4 processes share something (devices such as terminal, keyboard, mouse, etc., or data structures) and can affect each other non deterministic Not exactly
More informationDo not start the test until instructed to do so!
CS 3204 Operating Systems Midterm (Abrams) Spring 2004 VIRG INIA POLYTECHNIC INSTITUTE AND STATE U T PRO SI M UNI VERSI TY Instructions: Do not start the test until instructed to do so! Print your name
More informationMutual Exclusion: Classical Algorithms for Locks
Mutual Exclusion: Classical Algorithms for Locks John Mellor-Crummey Department of Computer Science Rice University johnmc@cs.rice.edu COMP 422 Lecture 18 21 March 2006 Motivation Ensure that a block of
More informationModels of concurrency & synchronization algorithms
Models of concurrency & synchronization algorithms Lecture 3 of TDA383/DIT390 (Concurrent Programming) Carlo A. Furia Chalmers University of Technology University of Gothenburg SP3 2016/2017 Today s menu
More informationDr. D. M. Akbar Hussain DE5 Department of Electronic Systems
Concurrency 1 Concurrency Execution of multiple processes. Multi-programming: Management of multiple processes within a uni- processor system, every system has this support, whether big, small or complex.
More informationThread Synchronization: Foundations. Properties. Safety properties. Edsger s perspective. Nothing bad happens
Edsger s perspective Testing can only prove the presence of bugs Thread Synchronization: Foundations Properties Property: a predicate that is evaluated over a run of the program (a trace) every message
More informationCS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2002
CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2002 Lecture 6: Synchronization 6.0 Main points More concurrency examples Synchronization primitives 6.1 A Larger Concurrent
More informationSolution: a lock (a/k/a mutex) public: virtual void unlock() =0;
1 Solution: a lock (a/k/a mutex) class BasicLock { public: virtual void lock() =0; virtual void unlock() =0; ; 2 Using a lock class Counter { public: int get_and_inc() { lock_.lock(); int old = count_;
More informationCoordination and Agreement
Coordination and Agreement Nicola Dragoni Embedded Systems Engineering DTU Informatics 1. Introduction 2. Distributed Mutual Exclusion 3. Elections 4. Multicast Communication 5. Consensus and related problems
More informationChapter 6: Process [& Thread] Synchronization. CSCI [4 6] 730 Operating Systems. Why does cooperation require synchronization?
Chapter 6: Process [& Thread] Synchronization CSCI [4 6] 730 Operating Systems Synchronization Part 1 : The Basics Why is synchronization needed? Synchronization Language/Definitions:» What are race conditions?»
More informationNotes for Recitation 8
6.04/8.06J Mathematics for Computer Science October 5, 00 Tom Leighton and Marten van Dijk Notes for Recitation 8 Build-up error Recall a graph is connected iff there is a path between every pair of its
More informationPeterson s Algorithm
Peterson s Algorithm public void lock() { flag[i] = true; victim = i; while (flag[j] && victim == i) {}; } public void unlock() { flag[i] = false; } 24/03/10 Art of Multiprocessor Programming 1 Mutual
More information! Why is synchronization needed? ! Synchronization Language/Definitions: ! How are locks implemented? Maria Hybinette, UGA
Chapter 6: Process [& Thread] Synchronization CSCI [4 6] 730 Operating Systems Synchronization Part 1 : The Basics! Why is synchronization needed?! Synchronization Language/Definitions:» What are race
More informationSafety and liveness for critical sections
Safety and liveness for critical sections! At most k threads are concurrently in the critical section A. Safety B. Liveness C. Both! A thread that wants to enter the critical section will eventually succeed
More informationThe concept of concurrency is fundamental to all these areas.
Chapter 5 Concurrency(I) The central themes of OS are all concerned with the management of processes and threads: such as multiprogramming, multiprocessing, and distributed processing. The concept of concurrency
More informationCSCI [4 6] 730 Operating Systems. Example Execution. Process [& Thread] Synchronization. Why does cooperation require synchronization?
Process [& Thread] Synchronization CSCI [4 6] 730 Operating Systems Synchronization Part 1 : The Basics Why is synchronization needed? Synchronization Language/Definitions: What are race conditions? What
More informationIntroduction to OS Synchronization MOS 2.3
Introduction to OS Synchronization MOS 2.3 Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Mahmoud El-Gayyar / Introduction to OS 1 Challenge How can we help processes synchronize with each other? E.g., how
More informationImplementing Mutual Exclusion. Sarah Diesburg Operating Systems CS 3430
Implementing Mutual Exclusion Sarah Diesburg Operating Systems CS 3430 From the Previous Lecture The too much milk example shows that writing concurrent programs directly with load and store instructions
More informationIntroduction to programming with semaphores Fri 1 Sep 2017
Introduction to programming with semaphores Fri 1 Sep 2017 K. V. S. Prasad Dept of Computer Science Chalmers University Lecture 2 of TDA384/DIT301, August October2017 Assignments? How s it going with the
More informationThe dining philosophers problem. CS 361 Concurrent programming Drexel University Fall 2004 Lecture 13
CS 361 Concurrent programming Drexel University Fall 2004 Lecture 13 Bruce Cha and Vera Zaychikr. All rights reserved by the author. Permission is given to students enrolled in CS361 Fall 2004 to reproduce
More informationLocks. Dongkun Shin, SKKU
Locks 1 Locks: The Basic Idea To implement a critical section A lock variable must be declared A lock variable holds the state of the lock Available (unlocked, free) Acquired (locked, held) Exactly one
More informationG52CON: Concepts of Concurrency
G52CON: Concepts of Concurrency Lecture 11: Semaphores I" Brian Logan School of Computer Science bsl@cs.nott.ac.uk Outline of this lecture" problems with Peterson s algorithm semaphores implementing semaphores
More informationLecture 7: Mutual Exclusion 2/16/12. slides adapted from The Art of Multiprocessor Programming, Herlihy and Shavit
Principles of Concurrency and Parallelism Lecture 7: Mutual Exclusion 2/16/12 slides adapted from The Art of Multiprocessor Programming, Herlihy and Shavit Time Absolute, true and mathematical time, of
More informationPart III Synchronization Software and Hardware Solutions
Part III Synchronization Software and Hardware Solutions Spring 2018 Computers are useless. They can only give answers. 1 Pablo Picasso Software Solutions for Two Processes Suppose we have two processes
More informationQuiz on Tuesday April 13. CS 361 Concurrent programming Drexel University Fall 2004 Lecture 4. Java facts and questions. Things to try in Java
CS 361 Concurrent programming Drexel University Fall 2004 Lecture 4 Bruce Char and Vera Zaychik. All rights reserved by the author. Permission is given to students enrolled in CS361 Fall 2004 to reproduce
More informationConcurrency Race Conditions and Deadlocks
Concurrency Race Conditions and Deadlocks Kartik Gopalan Chapters 2 (2.3) and 6 Tanenbaum s Modern OS Sequential Loosely, doing many things, but one after another E.g. Finish one assignment, then another
More informationThread Synchronization: Too Much Milk
Thread Synchronization: Too Much Milk 1 Implementing Critical Sections in Software Hard The following example will demonstrate the difficulty of providing mutual exclusion with memory reads and writes
More informationDistributed Mutual Exclusion Algorithms
Chapter 9 Distributed Mutual Exclusion Algorithms 9.1 Introduction Mutual exclusion is a fundamental problem in distributed computing systems. Mutual exclusion ensures that concurrent access of processes
More informationMutual Exclusion. Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit
Mutual Exclusion Companion slides for The by Maurice Herlihy & Nir Shavit Mutual Exclusion Today we will try to formalize our understanding of mutual exclusion We will also use the opportunity to show
More informationConcurrency, Mutual Exclusion and Synchronization C H A P T E R 5
Concurrency, Mutual Exclusion and Synchronization C H A P T E R 5 Multiple Processes OS design is concerned with the management of processes and threads: Multiprogramming Multiprocessing Distributed processing
More informationSPIN, PETERSON AND BAKERY LOCKS
Concurrent Programs reasoning about their execution proving correctness start by considering execution sequences CS4021/4521 2018 jones@scss.tcd.ie School of Computer Science and Statistics, Trinity College
More informationNeed for synchronization: If threads comprise parts of our software systems, then they must communicate.
Thread communication and synchronization There are two main aspects to Outline for Lecture 19 multithreaded programming in Java: I. Thread synchronization. thread lifecycle, and thread synchronization.
More informationIntroducing Shared-Memory Concurrency
Race Conditions and Atomic Blocks November 19, 2007 Why use concurrency? Communicating between threads Concurrency in Java/C Concurrency Computation where multiple things happen at the same time is inherently
More informationPROCESS SYNCHRONIZATION
PROCESS SYNCHRONIZATION Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization Monitors Synchronization
More informationOperating Systems. Lecture 4 - Concurrency and Synchronization. Master of Computer Science PUF - Hồ Chí Minh 2016/2017
Operating Systems Lecture 4 - Concurrency and Synchronization Adrien Krähenbühl Master of Computer Science PUF - Hồ Chí Minh 2016/2017 Mutual exclusion Hardware solutions Semaphores IPC: Message passing
More informationMidterm Exam Amy Murphy 19 March 2003
University of Rochester Midterm Exam Amy Murphy 19 March 2003 Computer Systems (CSC2/456) Read before beginning: Please write clearly. Illegible answers cannot be graded. Be sure to identify all of your
More informationInterprocess Communication By: Kaushik Vaghani
Interprocess Communication By: Kaushik Vaghani Background Race Condition: A situation where several processes access and manipulate the same data concurrently and the outcome of execution depends on the
More informationRemaining Contemplation Questions
Process Synchronisation Remaining Contemplation Questions 1. The first known correct software solution to the critical-section problem for two processes was developed by Dekker. The two processes, P0 and
More informationMore Shared Memory Programming
More Shared Memory Programming Shared data structures We want to make data structures that can be shared by threads. For example, our program to copy a file from one disk to another used a shared FIFO
More informationTemporal Logic of Actions (TLA) (a brief introduction) Shmuel Katz Computer Science Department The Technion
Temporal Logic of Actions (TLA) (a brief introduction) Shmuel Katz Computer Science Department The Technion CS236368 Formal Specifications Lecture-- TLA 1 Basic Idea Combine transitions with temporal logic
More informationCS 361 Concurrent programming Drexel University Spring 2000 Lecture 14. The dining philosophers problem
CS 361 Concurrent programming Drexel University Spring 2000 Lecture 14 Bruce Char. All rights reserved by the author. Permission is given to students enrolled in CS361 Spring 2000 to reproduce these notes
More informationBackground. The Critical-Section Problem Synchronisation Hardware Inefficient Spinning Semaphores Semaphore Examples Scheduling.
Background The Critical-Section Problem Background Race Conditions Solution Criteria to Critical-Section Problem Peterson s (Software) Solution Concurrent access to shared data may result in data inconsistency
More informationCSE 153 Design of Operating Systems
CSE 153 Design of Operating Systems Winter 19 Lecture 7/8: Synchronization (1) Administrivia How is Lab going? Be prepared with questions for this weeks Lab My impression from TAs is that you are on track
More informationUnit 6: Indeterminate Computation
Unit 6: Indeterminate Computation Martha A. Kim October 6, 2013 Introduction Until now, we have considered parallelizations of sequential programs. The parallelizations were deemed safe if the parallel
More informationLecture 2: Intro to Concurrent Processing. A Model of Concurrent Programming
Lecture 2: Intro to Concurrent Processing The SR Language. Correctness and Concurrency. Mutual Exclusion & Critical Sections. Software Solutions to Mutual Exclusion. Dekker s Algorithm. The Bakery Algorithm.
More informationFor more Articles Go To: Whatisdbms.com CONCURRENCY CONTROL PROTOCOL
For more Articles Go To: Whatisdbms.com CONCURRENCY CONTROL PROTOCOL In the multi-user system, we all know that multiple transactions run in parallel, thus trying to access the same data and suppose if
More informationLogic and Computation Lecture 20 CSU 290 Spring 2009 (Pucella) Thursday, Mar 12, 2009
Logic and Computation Lecture 20 CSU 290 Spring 2009 (Pucella) Thursday, Mar 12, 2009 Note that I change the name of the functions slightly in these notes from what I used in class, to be consistent with
More informationCollege of Computer & Information Science Spring 2010 Northeastern University 26 January 2010
College of Computer & Information Science Spring 2010 Northeastern University 26 January 2010 CS 7600: Intensive Computer Systems Scribe: Eric Miles In this lecture, we covered some of the (unwanted) behavior
More informationLecture 2: Intro to Concurrent Processing
Lecture 2: Intro to Concurrent Processing The SR Language. Correctness and Concurrency. Mutual Exclusion & Critical Sections. Software Solutions to Mutual Exclusion. Dekker s Algorithm. The Bakery Algorithm.
More informationIntroduction to Operating Systems
Introduction to Operating Systems Lecture 4: Process Synchronization MING GAO SE@ecnu (for course related communications) mgao@sei.ecnu.edu.cn Mar. 18, 2015 Outline 1 The synchronization problem 2 A roadmap
More informationConcurrency Control - Two-Phase Locking
Concurrency Control - Two-Phase Locking 1 Last time Conflict serializability Protocols to enforce it 2 Big Picture All schedules Want this as big as possible Conflict Serializable Schedules allowed by
More informationDistributed Systems. 13. Distributed Deadlock. Paul Krzyzanowski. Rutgers University. Fall 2017
Distributed Systems 13. Distributed Deadlock Paul Krzyzanowski Rutgers University Fall 2017 October 23, 2017 2014-2017 Paul Krzyzanowski 1 Deadlock Four conditions for deadlock 1. Mutual exclusion 2. Hold
More informationAssignment-2 (TCS/TIT 503)
Assignment-2 (TCS/TIT 503) Topics covered: Threads, Process Synchronisation, Semaphores Submission dates: 1)CS A:Monday,26/10/2015 (Time: between 12 pm to 1 pm) 2)CS B:Monday,26/10/2015(in the lecture
More informationLecture Topics. Announcements. Today: Concurrency: Mutual Exclusion (Stallings, chapter , 5.7)
Lecture Topics Today: Concurrency: Mutual Exclusion (Stallings, chapter 5.1-5.4, 5.7) Next: Concurrency: Deadlock and Starvation (Stallings, chapter 6.1, 6.6-6.8) 1 Announcements Self-Study Exercise #5
More informationChapter 6: Process Synchronization
Chapter 6: Process Synchronization Objectives Introduce Concept of Critical-Section Problem Hardware and Software Solutions of Critical-Section Problem Concept of Atomic Transaction Operating Systems CS
More informationSynchronization. Before We Begin. Synchronization. Credit/Debit Problem: Race Condition. CSE 120: Principles of Operating Systems.
CSE 120: Principles of Operating Systems Lecture 4 Synchronization January 23, 2006 Prof. Joe Pasquale Department of Computer Science and Engineering University of California, San Diego Before We Begin
More informationProgramming Languages
Programming Languages Tevfik Koşar Lecture - XXVI April 27 th, 2006 1 Roadmap Shared Memory Synchronization Spin Locks Barriers Semaphores Monitors 2 1 Memory Architectures Distributed Memory Shared Memory
More informationCSL373: Lecture 5 Deadlocks (no process runnable) + Scheduling (> 1 process runnable)
CSL373: Lecture 5 Deadlocks (no process runnable) + Scheduling (> 1 process runnable) Past & Present Have looked at two constraints: Mutual exclusion constraint between two events is a requirement that
More informationClassical Synchronization Problems. Copyright : University of Illinois CS 241 Staff 1
Classical Synchronization Problems 1 1 This lecture Goals: Topics Introduce classical synchronization problems Producer-Consumer Problem Reader-Writer Problem Dining Philosophers Problem Sleeping Barber
More informationCS1102: Macros and Recursion
CS1102: Macros and Recursion Kathi Fisler, WPI October 5, 2009 This lecture looks at several more macro examples. It aims to show you when you can use recursion safely with macros and when you can t. 1
More informationCS 111X - Fall Test 1
CS 111X - Fall 2016 - Test 1 1/9 Computing ID: CS 111X - Fall 2016 - Test 1 Name: Computing ID: On my honor as a student, I have neither given nor received unauthorized assistance on this exam. Signature:
More informationCMPS 111 Spring 2013 Prof. Scott A. Brandt Midterm Examination May 6, Name: ID:
CMPS 111 Spring 2013 Prof. Scott A. Brandt Midterm Examination May 6, 2013 Name: ID: This is a closed note, closed book exam. There are 23 multiple choice questions, 6 short answer questions. Plan your
More informationOperating Systems. Synchronisation Part I
Operating Systems Synchronisation Part I Process Synchronisation How do processes synchronise their operation to perform a task? Key concepts: Critical sections Mutual exclusion Atomic operations Race
More informationRecursively Enumerable Languages, Turing Machines, and Decidability
Recursively Enumerable Languages, Turing Machines, and Decidability 1 Problem Reduction: Basic Concepts and Analogies The concept of problem reduction is simple at a high level. You simply take an algorithm
More informationFinal Examination CS 111, Fall 2016 UCLA. Name:
Final Examination CS 111, Fall 2016 UCLA Name: This is an open book, open note test. You may use electronic devices to take the test, but may not access the network during the test. You have three hours
More informationCOMP 300E Operating Systems Fall Semester 2011 Midterm Examination SAMPLE. Name: Student ID:
COMP 300E Operating Systems Fall Semester 2011 Midterm Examination SAMPLE Time/Date: 5:30 6:30 pm Oct 19, 2011 (Wed) Name: Student ID: 1. Short Q&A 1.1 Explain the convoy effect with FCFS scheduling algorithm.
More informationLecture 8: September 30
CMPSCI 377 Operating Systems Fall 2013 Lecture 8: September 30 Lecturer: Prashant Shenoy Scribe: Armand Halbert 8.1 Semaphores A semaphore is a more generalized form of a lock that can be used to regulate
More informationConcurrency: Mutual Exclusion and Synchronization. Concurrency
Concurrency: Mutual Exclusion and Synchronization Chapter 5 1 Concurrency Multiple applications Structured applications Operating system structure 2 1 Concurrency 3 Difficulties of Concurrency Sharing
More informationFirst Midterm Exam September 28, 2017 CS162 Operating Systems
University of California, Berkeley College of Engineering Computer Science Division EECS Fall 2017 Ion Stoica First Midterm Exam September 28, 2017 CS162 Operating Systems Your Name: SID AND 162 Login
More informationCS 31: Introduction to Computer Systems : Threads & Synchronization April 16-18, 2019
CS 31: Introduction to Computer Systems 22-23: Threads & Synchronization April 16-18, 2019 Making Programs Run Faster We all like how fast computers are In the old days (1980 s - 2005): Algorithm too slow?
More informationCS 111. Operating Systems Peter Reiher
Operating System Principles: Mutual Exclusion and Asynchronous Completion Operating Systems Peter Reiher Page 1 Outline Mutual Exclusion Asynchronous Completions Page 2 Mutual Exclusion Critical sections
More informationComputing with Infinitely Many Processes under assumptions on concurrency and participation -M.Merritt&G.Taubenfeld. Dean Christakos & Deva Seetharam
Computing with Infinitely Many Processes under assumptions on concurrency and participation -M.Merritt&G.Taubenfeld Dean Christakos & Deva Seetharam November 25, 2003 Abstract This paper explores four
More informationSynchronization: Semaphores
Illinois Institute of Technology Lecture 26 4/25 solved Synchronization: Semaphores CS 536: Science of Programming, Spring 2018 A. Why Avoiding interference, while good, isn t the same as coordinating
More informationConcurrency pros and cons. Concurrent Programming Problems. Linked list example. Linked list example. Mutual Exclusion. Concurrency is good for users
Concurrency pros and cons Con Programming Problems OS Spring 2011 Concurrency is good for users One of the reasons for multiprogramming Working on the same problem, simultaneous execution of programs,
More informationBackground. Old Producer Process Code. Improving the Bounded Buffer. Old Consumer Process Code
Old Producer Process Code Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms to ensure the orderly execution of cooperating processes Our
More informationShared Variables and Interference
Solved Shared Variables and Interference CS 536: Science of Programming, Fall 2018 A. Why Parallel programs can coordinate their work using shared variables, but it s important for threads to not interfere
More informationCS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University
Frequently asked questions from the previous class survey CS 370: SYSTEM ARCHITECTURE & SOFTWARE [PROCESS SYNCHRONIZATION] Shrideep Pallickara Computer Science Colorado State University Semaphores From
More informationHomework Assignment #4. Some of the questions are taken from the textbook, Operating Systems, Principles and Practice, by T. Anderson and M. Dahlin.
CISC 3595/5595 Operating System Fall, 2015 Homework Assignment #4 Some of the questions are taken from the textbook, Operating Systems, Principles and Practice, by T. Anderson and M. Dahlin. 1 For the
More informationChapter 6: Process Synchronization. Operating System Concepts 8 th Edition,
Chapter 6: Process Synchronization, Silberschatz, Galvin and Gagne 2009 Module 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores
More informationMotivation of Threads. Preview. Motivation of Threads. Motivation of Threads. Motivation of Threads. Motivation of Threads 9/12/2018.
Preview Motivation of Thread Thread Implementation User s space Kernel s space Inter-Process Communication Race Condition Mutual Exclusion Solutions with Busy Waiting Disabling Interrupt Lock Variable
More informationProcess Management And Synchronization
Process Management And Synchronization In a single processor multiprogramming system the processor switches between the various jobs until to finish the execution of all jobs. These jobs will share the
More informationCMPT 300 Introduction to Operating Systems
CMPT 300 Introduction to Operating Systems Introduction to Deadlocks 1 Preemptible resources Resources that can be taken away from a process without adversely affecting outcome Example: memory (swapping)
More informationDatabase Management System Prof. D. Janakiram Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.
Database Management System Prof. D. Janakiram Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No. # 20 Concurrency Control Part -1 Foundations for concurrency
More informationChapter 5 Asynchronous Concurrent Execution
Chapter 5 Asynchronous Concurrent Execution Outline 5.1 Introduction 5.2 Mutual Exclusion 5.2.1 Java Multithreading Case Study 5.2.2 Critical Sections 5.2.3 Mutual Exclusion Primitives 5.3 Implementing
More informationCS 318 Principles of Operating Systems
CS 318 Principles of Operating Systems Fall 2017 Lecture 8: Deadlock Ryan Huang Administrivia Lab 1 deadline extended - Friday 09/29 11:59 pm - Saturday 09/30 11:59 pm [Hard] HW2 out - should try to solve
More informationAtomicity and Virtualization. Atomicity. Critical section. Edsger s perspective. Virtualizing a resource requires managing concurrent accesses
Atomicity and Virtualization Atomicity Virtualizing a resource requires managing concurrent accesses data structures must transition between consistent states atomic actions transform state indivisibly
More informationQuiz Answers. CS 537 Lecture 9 Deadlock. What can go wrong? Readers and Writers Monitor Example
Quiz Answers CS 537 Lecture 9 Deadlock Use of disabling interrupts Not allowed by processor --> requires system call Not safe is usermode code buggy and allowed by processor Locking Just lock manipulation
More informationAlgorithmic Verification. Algorithmic Verification. Model checking. Algorithmic verification. The software crisis (and hardware as well)
Algorithmic Verification The software crisis (and hardware as well) Algorithmic Verification Comp4151 Lecture 1-B Ansgar Fehnker Computer become more powerful (Moore s law) The quality of programs cannot
More informationSystem Correctness. EEC 421/521: Software Engineering. System Correctness. The Problem at Hand. A system is correct when it meets its requirements
System Correctness EEC 421/521: Software Engineering A Whirlwind Intro to Software Model Checking A system is correct when it meets its requirements a design without requirements cannot be right or wrong,
More informationMidterm Exam Amy Murphy 6 March 2002
University of Rochester Midterm Exam Amy Murphy 6 March 2002 Computer Systems (CSC2/456) Read before beginning: Please write clearly. Illegible answers cannot be graded. Be sure to identify all of your
More informationThe Deadlock Lecture
Concurrent systems Lecture 4: Deadlock, Livelock, and Priority Inversion DrRobert N. M. Watson The Deadlock Lecture 1 Reminder from last time Multi-Reader Single-Writer (MRSW) locks Alternatives to semaphores/locks:
More informationParallel access to linked data structures
Parallel access to linked data structures [Solihin Ch. 5] Answer the questions below. Name some linked data structures. What operations can be performed on all of these structures? Why is it hard to parallelize
More informationELEMENTARY NUMBER THEORY AND METHODS OF PROOF
CHAPTER 4 ELEMENTARY NUMBER THEORY AND METHODS OF PROOF Copyright Cengage Learning. All rights reserved. SECTION 4.6 Indirect Argument: Contradiction and Contraposition Copyright Cengage Learning. All
More information