General information


This session is dedicated to the synchronization among threads / processes

You don't have to submit source files or reports for this sessions. For this session, you will need to log into a PC running Linux. If you are at Eurecom, simply log on a PC of rooms 52 or 53.

I. Why is synchronization necessary?

  1. Open the slides on Synchronization

  2. Watch the video on an introduction to synchronization

II. Implementing critical sections

  1. Open the slides on Synchronization, second section

  2. Watch the video on the implementation of critical sections

III. Programming with synchronization constraints

  1. Open the slides Synchronization, last section

  2. Watch the video on how to handle synchronization in code

  3. Have a look at the faulty code and try to understand why data can be equal to -1.
  4. (Help me!) The problem comes from the use of if. Actually, when a signal is sent on a condition variables, all waiting processes are awoken. So, for instance, two consumers could be awoken if data is equal to 2. The two awoken consumers will decrease data of, thus leading to data = -1. If the "if" is replaced with a "while", a process can only execute "data --" if data > 0

IV. Robot session

Work on the robot. Today, what is important is to decide on an architecture and to setup an easy-to-use software development environment.