UC3M

Telematic/Audiovisual Syst./Communication Syst. Engineering

Systems Architecture

September 2017 - January 2018

Milestone 5: Concurrent autosave

Previous activities

1.  The Helgrind tool

Resources

  • File test.c that you have to download in your current directory.

Work Plan

Answer the following questions:

  1. Read the helgrind documentation. What kind of errors does helgrind detect?

  2. Generate an executable from test.c (compiling with the option-lpthread of the gcc) and run it with helgrind. What information about errors is given? Specify the line in which the program fails.

2.  Using threads (pthreads), mutex and condition variables

Resources

Work Plan

  1. Compile helloThreads.c, run it several times and understand how it works.

  2. Based on the previous example of threads creation, race.c introduces a counter that is shared among the threads and incremented by them. Compile race.c and execute it several times. What is the final value of the counter? Why does it happen? Fix the code by using mutex. You can use helgrind to understand and detect problems.

  3. Optionally: modify race.c to add a new thread that waits until the count variable reaches a specified value (COUNT_LIMIT) (Recomendation: use helgrind to detect errors).