Introduction to Concurrency

Slides:



Advertisements
Similar presentations
Silberschatz, Galvin and Gagne ©2007 Operating System Concepts with Java – 7 th Edition, Nov 15, 2006 Chapter 6 (a): Synchronization.
Advertisements

1 Operating Systems, 122 Practical Session 5, Synchronization 1.
Multithreading. RHS – SWC 2 What is a thread Inside a single process, multiple threads can be executing concurrently A thread is the execution of (part.
Necessity of Systematic & Automated Testing Techniques Moonzoo Kim CS Dept, KAIST.
1 Concurrency Specification. 2 Outline 4 Issues in concurrent systems 4 Programming language support for concurrency 4 Concurrency analysis - A specification.
Race Conditions. Isolated & Non-Isolated Processes Isolated: Do not share state with other processes –The output of process is unaffected by run of other.
CS444/CS544 Operating Systems Synchronization 2/16/2006 Prof. Searleman
Concurrent Processes Lecture 5. Introduction Modern operating systems can handle more than one process at a time System scheduler manages processes and.
UCoM Software Architecture Universal Communicator Research UCoM Programming Model The Problem  Multi-threaded code is difficult to write.
TI1400 Ten Minutes of Personal Notes on Being a TU Delft Student Alexandru Iosup (lecturer) Parallel and Distributed Systems
CS510 Concurrent Systems Class 5 Threads Cannot Be Implemented As a Library.
Parrot: A Practical Runtime for Deterministic, Stable, and Reliable threads HEMING CUI, YI-HONG LIN, HAO LI, XINAN XU, JUNFENG YANG, JIRI SIMSA, BEN BLUM,
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
Why The Grass May Not Be Greener On The Other Side: A Comparison of Locking vs. Transactional Memory Written by: Paul E. McKenney Jonathan Walpole Maged.
Concurrency Recitation – 2/24 Nisarg Raval Slides by Prof. Landon Cox.
1 Lecture 9: Synchronization  concurrency examples and the need for synchronization  definition of mutual exclusion (MX)  programming solutions for.
1 Thread Synchronization: Too Much Milk. 2 Implementing Critical Sections in Software Hard The following example will demonstrate the difficulty of providing.
Programming Paradigms for Concurrency Part 2: Transactional Memories Vasu Singh
CS 153 Design of Operating Systems Spring 2015 Lecture 11: Scheduling & Deadlock.
COMP 111 Threads and concurrency Sept 28, Tufts University Computer Science2 Who is this guy? I am not Prof. Couch Obvious? Sam Guyer New assistant.
CS162 Week 5 Kyle Dewey. Overview Announcements Reactive Imperative Programming Parallelism Software transactional memory.
Debugging Threaded Applications By Andrew Binstock CMPS Parallel.
Software Construction Lecture 19 Software Testing-2.
Introduction to Operating Systems Prepared by: Dhason Operating Systems.
Concurrency Analysis for Correct Concurrent Programs: Fight Complexity Systematically and Efficiently Moonzoo Kim Computer Science, KAIST.
/ PSWLAB Thread Modular Model Checking by Cormac Flanagan and Shaz Qadeer (published in Spin’03) Hong,Shin Thread Modular Model.
CS 153 Design of Operating Systems Winter 2016 Lecture 7: Synchronization.
Agenda  Quick Review  Finish Introduction  Java Threads.
Introduction to operating systems What is an operating system? An operating system is a program that, from a programmer’s perspective, adds a variety of.
Synchronization Questions answered in this lecture: Why is synchronization necessary? What are race conditions, critical sections, and atomic operations?
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
Threads Some of these slides were originally made by Dr. Roger deBry. They include text, figures, and information from this class’s textbook, Operating.
Healing Data Races On-The-Fly
Multithreading / Concurrency
Sarah Diesburg Operating Systems COP 4610
Moonzoo Kim SWTV Group CS Dept. KAIST
Advanced Topics in Concurrency and Reactive Programming: Asynchronous Programming Majeed Kassis.
Concurrency.
COMPSCI210 Recitation 12 Oct 2012 Vamsi Thummala
Multiple Writers and Races
Lecture 21 Concurrency Introduction
Locking cs205: engineering software
COP 4600 Operating Systems Fall 2010
Introduction to Concurrent Programming
Multi-Processing in High Performance Computer Architecture:
Concurrency Specification
Lecture 11: Mutual Exclusion
Lecture 15: Concurring Concurrently CS201j: Engineering Software
Atomicity in Multithreaded Software
Chapter 26 Concurrency and Thread
Miscellaneous Thoughts Nothing on the APIs
Quality Concurrent SW - Fight the Complexity of SW
Background and Motivation
cs205: engineering software
Moonzoo Kim SWTV Group CS Dept. KAIST
Multithread Programming
Concurrency: Mutual Exclusion and Process Synchronization
Operating System Introduction.
Lecture 11: Mutual Exclusion
Why Threads Are A Bad Idea (for most purposes)
CSE 451: Operating Systems Autumn 2003 Lecture 7 Synchronization
CSE 451: Operating Systems Autumn 2005 Lecture 7 Synchronization
Why Threads Are A Bad Idea (for most purposes)
CS561 Computer Architecture Hye Yeon Kim
Why Threads Are A Bad Idea (for most purposes)
EECE.4810/EECE.5730 Operating Systems
EECE.4810/EECE.5730 Operating Systems
EECE.4810/EECE.5730 Operating Systems
Don Porter Portions courtesy Emmett Witchel
Sarah Diesburg Operating Systems CS 3430
Presentation transcript:

Introduction to Concurrency CS 5334/4390 Lecture January 16, 2017 Shirley Moore svmoore@utep.edu

Motivation for Studying Concurrency Most of my subjects (interviewees) have found that the hardest bugs to track down are in concurrent code … And almost every one seems to think that ubiquitous multi-core CPUs are going to force some serious changes in the way software is written. P. Siebel, Coders at Work (2009) -- interviews with 15 top programmers of our times: Jamie Zawinski, Brad Fitzpatrick, Douglas Crockford, Brendan Eich, Joshua Bloch, Joe Armstrong, Simon Peyton Jones, Peter Norvig, Guy Steele, Dan Ingalls, L Peter Deutsch, Ken Thompson, Fran Allen, Bernie Cosell, Donald Knuth

Concurrent Programming is Error-prone Correctness of concurrent programs is hard to achieve Interactions between threads are hard to reason about Thread executions with non-deterministic thread scheduling Testing techniques for sequential programs do not work 4 processes, 55043 states 3 processes, 853 states 2 processes , 30 states Input space v.s. thread scheduling space which is not under-control Peterson mutual exclusion (From Dr. Moritz Hammer’s Visualisierung ) Slide courtesy of Moonzoo Kim at KAIST

Concurrency example Concurrent programs have very high complexity due to non-deterministic scheduling Ex. int x=0, y=0, z =0; void p() {x=y+1; y=z+1; z= x+1;} void q() {y=z+1; z=x+1; x=y+1;} 20 interleaving scenarios = (3+3)!/(3!x3!) 11 unique outcomes p() x=y+1 y=z+1 z=x+1 q() y=z+1 z=x+1 x=y+1 x,y,z 2,1,2 2,1,3 2,2,3 2,3,3 2,4,3 3,2,3 4,3,2 4,3,5 Trail1: 2,2,3 Trail2: 3,2,4 Trail3: 3,2,3 Trail4: 2,4,3 Trail5: 5,4,6 Trail6: 5,4,3 Trail7: 2,1,3 Trail8: 2,3,3 Trail9: 4,3,5 Trail10: 4,3,2 Trail11: 2,1,2 Slide courtesy of Moonzoo Kim at KAIST

Very difficult to find concurrency bugs !!!

Call Stack for a Sequential Program

Call Stacks for a Multithreaded Program

Classic Concurrency Bugs Nondeterminism (not a bug by itself, but can make bugs hard to find) Example: Threads1.java Question: What causes the nondeterministic behavior? Race condition Example: PrimeCount<n>.java Question: Why is the result from PrimeCount3 incorrect when multiple threads are used? Deadlock and starvation: Example: DiningPhilosophers.java Group activity: Design a solution that prevents deadlock Design a solution that prevents both deadlock and starvation

Feedback on today’s class (do this now!) Send email to svmoore@utep.edu with answers to these three questions: What was the most important thing you learned today? What did you learn today that most surprised you? (Ok to say nothing if nothing surprised you) What are you most unclear about from today’s class? (Ok to say nothing if everything was crystal clear)

Preparation for Next Class (do this now!) We’ll be using Stampede for this course, starting next class. Go to portal.xsede.org and create an XSEDE portal account if you don’t already have one. Send you XSEDE username to svmoore@utep.edu to be added to the education allocation for the course.