This course is worth 6 cu, if you have done the 2 cu project, and otherwise 4 cu.
If you have done the 2 cu project with a lecture course, please mention about it and give the year.
Write in each answer sheet course name, date, your name, signature and student id.
- [9 p] Critical section.
- Give a code level example on a critical section. Give a scenario (relating to your example situation), where computation result is erroneous if critical section is not protected properly.
- Explain, why the computation result in that same scenario is correct when critical section is protected. Why is the result now correct in all possible scenarios?
- Which critical section protection method would be good for this situation? Why this method and not one of the two other methods that you know of? Explain. Show how critical section protection is implemented at pseudo code level in this case.
- [9 p] Deadlocks.
- [2 p] What is the deadlock problem? Give a concrete (pseudocode) example on deadlock.
- [3 p] How can deadlock be detected? What does one do, if deadlock is found?
- [2 p] Explain the main principles of Banker's algorithm to prevent deadlocks from occurring. How would it work in your example in part (a)?
- [2 p] Give some other concrete method than Banker's algorithm to prevent deadlocks from occurring. What principle is the solution based on? How would it work in your example in part (a).
- [9 p] Semaphors and Monitor.
- How is critical section problem solved in monitor? How does the solution differ from critical section solution with semaphors?
- How is synchronization problem solved in monitor? How does the solution differ from critical section solution with semaphors?
- Explain the concept "monitor signalling semantics". How does if affect (i) monitor implementation, and (ii) implementation of the routine calling the monitr?
- [9 p] Producer-Consumer problem with semafors. There are one each. Buffer size is infinite
- [2 p] Describe the problem. Especially explain, what synchronization and communication problems are involved.
- [2 p] What does "infinitely large" buffer mean in practice, and how is it implemented in practice? How does this "infinitely large" buffer affect the solution logic (as compared to finite buffer case)?
- [5 p] Give a solution using semafors. Present the pseudocode for producer and consumer. Declare clearly all your semafores and other data structures with their initial values. Explain why your solution is correct.