1 / 10

Debugging Threaded Applications

Debugging Threaded Applications. By Andrew Binstock http://software.intel.com/sites/billboard/archive/debugging-threaded-applications.php CMPS 5433- Parallel Processing Halverson. Why?. PP difficult due to complexity of threads Concurrent threads = Speedup Correct design of threads

kat
Download Presentation

Debugging Threaded Applications

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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

More Related