If you want some practice before the midterm on synchrnoization problems, try the following:
You should solve a slightly different version of the Readers-Writers problem then we solved in class. In this version a reader must block if a writer is waiting (even if currently there are other readers reading). When it is safe for a reader to read, it can wake up any other readers that have been waiting to read too, but if a writer comes along while these readers are reading, then any subsequent reader trying to read must wait because there is now a writer now waiting. In this version starvation of readers or writers is not possible.
Hint: think about boundary cases, does the first reader need to do anything differently than subsequent readers, or does the last reader need to do anything differently than the first to stop reading, does the writer need to do anything special before or after it writes?
The Sleeping Barber Problem
In this problem you are to synchronize the actions of a barber and some number of customers. The barber can only cut one customer's hair at a time. A barber shop has one barber, one barber chair, and N chairs for waiting customers. If there are no customers the barber sits in the barber chair and falls asleep. When a customer arrives he/she has to wake up the sleeping barber. If a customers arrives while the barber is cutting hair, then if there is a free chair the customer sits down and waits, otherwise the customer leaves. Program the barber and the customers using semaphores to synchronize their actions. Your solution should be live, safe, and deadlock free. A couple suggestions: (1) I think it is easier to write the customer code first; (2) think about who can wake up whom (this will help you determine how many semaphores you need for your solution).