Question: Customer buyProduct () { while ( numProduct = = 0) { signal ( customers); wait (Product); } while (Product.NotEmpty)signal(Product); numProduct --; } Clerk sellProduct(){ if(numProduct!=0)wait(customers);

Customer buyProduct () {

while ( numProduct = = 0) {

signal ( customers);

wait (Product);

}

while (Product.NotEmpty)signal(Product);

numProduct --;

}

Clerk

sellProduct(){

if(numProduct!=0)wait(customers);

numProduct = P;

}

a) Change the code such that it will properly work with a Signal and Exit policy. Consider the monitor concept and not its java implementation.

b) What will be the outcome of eliminating if(numProduct!=0) in the clerk code? Clearly explain and give an execution sequence that shows the outcome.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!