Concurrent programming, exam 19.11.2010                           SuomeksiToisella puolella suomeksi
Write in each answer sheet course name, date, your name, signature and student id.
  1. [9 p] Critical section. 
    1. What is the critical section problem?
      Give a concrete example on a situation where critical section problem arises?
    2. When would it be reasonable to solve the critical section problem with busy wait loop and when not? Explain? How do you solve the problem with busy wait loop?
    3. When would it be reasonable to solve the critical section problem with semaphores and when not? Explain? How do you solve the problem with a semafore?
       
  2. [9 p] Deadlocks.
    1. What is the deadlock problem? Give a concrete example on deadlock, based on the Dining Philosophers problem.
    2. Which four conditions must be in effect for deadlock to occur? Show that they exist in your example.
    3. Explain the main principles of Dijktra's deadlock detection algorithm (DDA).
    4. How would you prevent deadlocks from occurring in the first place? Give one solution method and show how it works with Dining Philosophers problem.
       
  3. [9 p] Monitor.
    1. What is a monitor? How does a monitor solve critical section problem?
    2. Where in the monitor may the processes executing there need to wait for their execution turn? For each type, give an example which explains why/when a process ended up waiting and when/how they get to execute.
    3. What does the concept monitor signalling semantics mean? How do the monitor signalling semantics affect the implementation of the monitor? Give a concrete pseudo-instruction level example.
       
  4. [9 p] Producer Consumer problem. There are many producers and consumers, and buffer size (N) is finite. Describe the problem and give a semaphore based solution. What synchronization and/or communication problems are involved and how are they solved?