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
Get step-by-step solutions from verified subject matter experts
