Concurrent Programming, Autumn 2006, HW 5
These will be covered in practise session during the week 48, 27.11.-1.12.2006.- Exercise 6.6 from text book.
- Redo problem 3 in homework set 4 so that process synchronization is done with semaphores.
- Look at the Algorithm 6.21 in text book (p. 144).
Notice the typo in algorithm.
- Show that readers have priority over writers.
- Will the algorithm work, if all three semaphores would be busy-wait semaphores instead of the usual suspend-wait semaphores? Under which conditions one should/should not use busy-wait semaphores instead of the usual suspend-wait semaphores?
- Modify the algorithm so that writers have priority over readers. Why would one want to do it this way?
- Look at the Algorithm 6.21 in text book (p. 144). Notice the typo in algorithm.
- Modify the algorithm so that the last writer will wake up all waiting readers. Notice that you must modify also the entry protocol for readers. Why would one want to do it this way?
- Modify the algorithm so that readers and writers have alternating priority. Why would one want to do it this way?
- Create a symmetric solution to the Dining Phisophers problem. All philosophers need the use exactly the same algorithm, which is not bound to the philosophers identity number. (The algorithm 6.12 in text book is a good asymmetric algorithm, because philosopher 4 uses different algorithm than the others.) Show that your algorithm does not cause deadlocks and that the philosophers do not starve and do not wait unnecessarily. [Andr00]
- Hint 1: Flip a coin to select which fork to pick up first.
- Hint 2: Extra variables with which fast thinking philosophers can be kept in line.
Teemu Kerola 22.11.2006 16:44