Homework 6: Synchronization and communication
CSE 410, Autumn 1999
Due in class, November 15th

Reading

Threads: S+G Chapter 4 section 5
Synchronization: S+G Chapter 6 sections 1-5, 7. If you like, ignore the following subsections: 6.2.1, 6.2.2, 6.5.1.

To be turned in

1. S+G exercises 4.6, 4.7

2. S+G exercise 6.1

3. S+G exercise 6.6. By wait and signal, the question is referring to the semaphore operations P() and V() discussed in class. To answer the question, you should show an interleaving of statements that leads to a violation of mutual exclusion.

4. S+G exercise 6.7. Use semaphores to implement your synchronization. A solution without any synchronization in it would look like this:

Of course, this solution will quickly run into trouble because multiple threads are accessing shared data. Add the necessary synchronization to protect access to the shared data. You may need to get rid of some of the provided code. Also, in your solution, the barber should never "wake up" unless there's a customer.