0

I'm doing my first parallel programming assignment and have very little idea what I'm doing with the whole mutex locking situation.

I'm trying to use Helgrind to locate race conditions in my code, and when I have locks where I think they should be, Helgrind returns an astonishing 7300 errors! However, removing some locks in a critical section actually reduces my errors to 6000, though I know this an area where locks are necessary.

What could be causing this? And maybe as a general statement could someone give me a reference to a good source explaining mutex locks for newbies? Thank you!

Jason Block
  • 155
  • 1
  • 3
  • 9

1 Answers1

1

First, Helgrind not only detects races but also detects misuses of mutexes, including recursive locking of non-recursive mutexes, unlocking mutexes that haven't previously been locked, etc. etc. By removing calls to pthread_mutex_*, you may simply be removing errors due to misuse of the mutex API. The Helgrind manual page has an extensive description of the kinds of errors that Helgrind detects.

Second, dynamic race detectors like Helgrind are notorious for producing many error messages -- often, too many to be useful. You should try it with as small a code fragment as possible first, so you are not overwhelmed by error reports.

EmeryBerger
  • 3,897
  • 18
  • 29