Debugging Threaded Applications By Andrew Binstock CMPS 5433- Parallel.

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

Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community.
CS492B Analysis of Concurrent Programs Lock Basics Jaehyuk Huh Computer Science, KAIST.
CSEN5322 Quiz-5.
5.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 5: CPU Scheduling.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Concurrency 101 Shared state. Part 1: General Concepts 2.
1 Concurrency Specification. 2 Outline 4 Issues in concurrent systems 4 Programming language support for concurrency 4 Concurrency analysis - A specification.
Data and Database Administration Chapter 12. Outline What is Concurrency Control? Background Serializability  Locking mechanisms.
“THREADS CANNOT BE IMPLEMENTED AS A LIBRARY” HANS-J. BOEHM, HP LABS Presented by Seema Saijpaul CS-510.
Review: Process Management Objective: –Enable fair multi-user, multiprocess computing on limited physical resources –Security and efficiency Process: running.
Deadlock Prevention CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
Synchronization in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
Synchronization CSCI 444/544 Operating Systems Fall 2008.
1 CSCI 6900: Design, Implementation, and Verification of Concurrent Software Eileen Kraemer August 19 th, 2010 The University of Georgia.
Concurrency Recitation – 2/24 Nisarg Raval Slides by Prof. Landon Cox.
1 Concurrency: Deadlock and Starvation Chapter 6.
1 Advanced Computer Programming Concurrency Multithreaded Programs Copyright © Texas Education Agency, 2013.
CS 153 Design of Operating Systems Spring 2015 Lecture 11: Scheduling & Deadlock.
© 2004, D. J. Foreman 1 High Level Synchronization and Inter-Process Communication.
Threads in Java. History  Process is a program in execution  Has stack/heap memory  Has a program counter  Multiuser operating systems since the sixties.
The HDF Group Multi-threading in HDF5: Paths Forward Current implementation - Future directions May 30-31, 2012HDF5 Workshop at PSI 1.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Introduction to Concurrency.
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.
Operating Systems CMPSC 473 Mutual Exclusion Lecture 14: October 14, 2010 Instructor: Bhuvan Urgaonkar.
Games Development 2 Concurrent Programming CO3301 Week 9.
Parallel Processing Sharing the load. Inside a Processor Chip in Package Circuits Primarily Crystalline Silicon 1 mm – 25 mm on a side 100 million to.
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.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Mutual Exclusion.
Chapter 7 -1 CHAPTER 7 PROCESS SYNCHRONIZATION CGS Operating System Concepts UCF, Spring 2004.
CCR Deadlock By: Laura Weiland April 30, Project Description Implement a module to the Train Operating System (TOS) that manages the deadlock problem.
Chapter 6 – Process Synchronisation (Pgs 225 – 267)
Concurrency Control 1 Fall 2014 CS7020: Game Design and Development.
Threads Tutorial #7 CPSC 261. A thread is a virtual processor Each thread is provided the illusion that it owns a core – Copy of the registers – It is.
CS510 Concurrent Systems Why the Grass May Not Be Greener on the Other Side: A Comparison of Locking and Transactional Memory.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Concurrency & Dynamic Programming.
CMSC 330: Organization of Programming Languages Threads.
CS 241 Section Week #7 (10/22/09). Topics This Section  Midterm Statistics  MP5 Forward  Classical Synchronization Problems  Problems.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
Lecture 3 Concurrency and Thread Synchronization     Mutual Exclusion         Dekker's Algorithm         Lamport's Bakery Algorithm.
Eraser: A dynamic Data Race Detector for Multithreaded Programs Stefan Savage, Michael Burrows, Greg Nelson, Patrick Sobalvarro, Thomas Anderson Presenter:
6.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Module 6: Process Synchronization.
Deadlocks Mark Stanovich Operating Systems COP 4610.
CS 151: Object-Oriented Design November 26 Class Meeting Department of Computer Science San Jose State University Fall 2013 Instructor: Ron Mak
CSCI1600: Embedded and Real Time Software Lecture 17: Concurrent Programming Steven Reiss, Fall 2015.
Proving Correctness and Measuring Performance CET306 Harry R. Erwin University of Sunderland.
1 5-High-Performance Embedded Systems using Concurrent Process (cont.)
© 2004, D. J. Foreman 1 Monitors and Inter-Process Communication.
Using Escape Analysis in Dynamic Data Race Detection Emma Harrington `15 Williams College
Mergesort example: Merge as we return from recursive calls Merge Divide 1 element 829.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community.
CSE 120 Principles of Operating
Background on the need for Synchronization
G.Anuradha Reference: William Stallings
Multiple Writers and Races
143a discussion session week 3
Concurrency Specification
COP 4600 Operating Systems Fall 2010
Concurrency in Java Last Updated: Fall 2010 Paul Ammann SWE 619.
Background and Motivation
Parallelism and Concurrency
Concurrency: Mutual Exclusion and Process Synchronization
Kernel Synchronization I
Kernel Synchronization II
CS333 Intro to Operating Systems
CSE 542: Operating Systems
CSE 542: Operating Systems
Presentation transcript:

Debugging Threaded Applications By Andrew Binstock CMPS Parallel Processing Halverson

Why? PP difficult due to complexity of threads Concurrent threads = Speedup Correct design of threads –Orderly –Well designed –Predictable Interference among threads causes problems

Threading Bugs When 2 threads interact –One sends a result to another When 2 threads share a common data variable –Updating a shared array

Common Violations TRY TO AVOID Data Races Deadlocks Live Locks

Data Race Occurs: When 2 threads share variable but don’t guard against simultaneous access E.G. Selecting seat on an airplane Recognize: Inconsistent results using same data Cause: No mutual exclusion on shared variable Prevention: Use mutual exclusion (lock)

Deadlock Occurs: Two or more threads blocked as each waits on a lock held by the other E.G. Combat game – clearing street & removing snipers Recognize: Threads don’t advance; program may freeze Cause: Failure to identify dependence; acquiring locks in wrong order –E.G. Game record score – display & record

Deadlock (cont’d) Avoid: –Required order of acquiring locks –Release one lock of second is not available

Live Lock Occurs: Multiple threads do not advance though actively working –Often - Algorithm flaw, not implementation E.G. Dining Philosophers Problem –If all 5 act synchronously Recognize: Multiple threads and/or program freeze or infinitely loop

Live Lock (cont’d) Hard to reproduce –May be hardware dependent 4 cores vs. 2 cores vs. more Prevention: Consider what happens if all threads run simultaneously

The Commercial Ad Intel Thread Checker Intel Thread Profiler Intel Threading Building Blocks Tools available to assist in –Running threads –Monitors threads –Identifies deadlock & race conditions 10