CMPSCI 377: Operating Systems

Homework 2

Due: Oct 24, 2014

Note: Please submit your solutions via moodle.
  1. What is a condition varaible and explain a typical syncronization scenario where it is used? Why does a condition variable involve releasing a lock when going to sleep?
  2. Describe an example scenario where using an "if" statement instead of a while when using condition variable can cause problems when using Mesa-style monitor. Based on this example, explain why correct usage of condition variable requires a "while" loop to check the condition for which the condition variable is used.
  3. Why do Hoare-style monitors not require the while for condition variables?
  4. Explain why allowing multiple readers to read a shared variable concurrently in the ReaderWriters problem will not impact correctness so long as writers are blocked.
  5. Consider the dining philosophers problem discussed in Lecture 9, slide 18. Explain what the putdown method is doing. Also explain how the the putdown method wakes up a philosopher waiting for a fork.
  6. What are the four necessary conditions for a deadlock? Give a simple example to show why these conditions are not sufficient.