Presentation is loading. Please wait.

Presentation is loading. Please wait.

Debugging Threaded Applications By Andrew Binstock CMPS 5433- Parallel.

Similar presentations


Presentation on theme: "Debugging Threaded Applications By Andrew Binstock CMPS 5433- Parallel."— Presentation transcript:

1 Debugging Threaded Applications By Andrew Binstock http://software.intel.com/sites/billboard/archive/debugging-threaded-applications.php CMPS 5433- Parallel Processing Halverson

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

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

4 Common Violations TRY TO AVOID Data Races Deadlocks Live Locks

5 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)

6 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

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

8 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

9 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

10 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


Download ppt "Debugging Threaded Applications By Andrew Binstock CMPS 5433- Parallel."

Similar presentations


Ads by Google