Question
Consider the following savage-cook monitor version. 1. Consider the first version of the implementation in which we had only one signal in each method. Given
1. Consider the first version of the implementation in which we had only one signal in each method.
Given service methods: getServing(), putServings(), with local variables size = M and #servings = 0, and queues EmptyPot and Food.
getServing(){ while (#servings == 0){
signal(EmptyPot);
wait(Food); }
#Servings--;
}
putServings(){ If(#servings != 0) wait(EmptyPot);
#servings = M; If(Food.queue! empty)signal(Food);
}
A. Give the execution sequence (by following the code) that showsdeadlock. Give the execution sequence (by following the code) that showsdelay.(depending on the fact that savage execution code is or is not a while(true) loop).
2. Do we need to have if (#servings >0) wait(EmptyPot) in the Cook pseudo-code ? Or, since if a savage finds the pot empty it will signal the Cook anyway, wait(EmptyPot) only is enough. What will be the outcome of the above change? (what condition of Critical Section Problem might be violated?) Give the execution sequence that will show it.
3. Consider the correct implementation (either with a platoon policy on the savage code or multiple signals on the cook code). The savage waits if there is no food, the cook waits if there is food.
a. Can we, instead of two condition variables, use only one? (lets say: potStatus). Discuss.
b. Is the assumption: If we have only one condition variable PotStatus, savage and cook cannot block at the same time on the condition variable correct?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started