Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 service methods: getServing(), putServings(), with local variables size = M and #servings = 0, and condition variables Food and NoFood.

GetServing(){

while (#servings == 0) {

signal(NoFood);

wait(Food);

}

#Servings--;

}

PutServing():

If(#servings != 0) wait(NoFood);

#servings = M;

signal(Food);

Give the execution sequence that shows deadlock or delay (depending on the fact that savages execution code is or is not a while(true) loop).

2. Do we need to have if (#servings != 0) wait(NoFood) in the Cook pseudo-code ? Or, since if a savage finds the pot empty it will signal the Cook anyway and wait(NoFood) 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. The savage waits for Food, the cook waits for NoFood. a. Can we, instead of two condition variables, use only one? (lets say: potStatus). Discuss. What will be the outcome of the change. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

2. Show the trainees how to do it without saying anything.

Answered: 1 week ago