Download presentation
Presentation is loading. Please wait.
Published byLuke Atkins Modified over 9 years ago
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
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.