This lesson introduces you to the debugging tool Helgrind, which you will use in the exercise in the proceeding lesson.

In this chapter’s exercise, you’ll use a real tool on Linux to find problems in multi-threaded code. The tool is called helgrind (available as part of the Valgrind suite of debugging tools

To complete these exercises locally, you’ll have to download and install Valgrind and the related helgrind tool. See for details about the tool, including how to download and install it locally (if it’s not already on your Linux system).

The installation has already been done for you in the widgets on our platform.

You’ll then look at a number of multi-threaded C programs to see how you can use the tool to debug problematic threaded code.

Then, type “make” to build all the different programs. Examine the Makefile for more details on how that works.

Then, you have a few different C programs to look at:

  • main-race.c: A simple race condition

  • main-deadlock.c: A simple deadlock

  • main-deadlock-global.c: A solution to the deadlock problem

  • main-signal.c: A simple child/parent signaling example

  • main-signal-cv.c: A more efficient signaling via condition variables

  • mythreads.h: Header file with wrappers to make code check errors and be more readable

Get hands-on with 1200+ tech skills courses.