Project comments How did it go? What was difficult? How did the hand in go? What can we do to make it easier?
Homework 3 General comments: –You need a mutex around all shared variables –If you have a condition variable and no monitor, you need a mutex –You can’t broadcast on a condition variable in a monitor –Don’t invent new synchronization constructs, unless you implement them with semaphores, mutexes, or condition variables: “Sleep”, “Awaken”, “Call asynchronous”
Homework 3 problems Sleeping Barbers –Need to keep a count of waiters, with a mutex –Need to wait for barber to finish cutting hair Smokers –Easiest to use a monitor. Need either 3 conditions, or one, and then serial wake-ups –If using semaphores, need to consider case where ingredients arrive out of order
Homework 3 problems (cont) Line printers: –Best solution: use a condition variable with a priority queue –Other solutions: have one condition variable per caller, and order those File access –Need to consider case where multiple waiters should be awoken