Question: The following is an incorrect solution to the bounded buffer problem (making use of a circular buffer). We use C-like syntax. The .wait and .signal
The following is an incorrect solution to the bounded buffer problem (making use of a circular buffer). We use C-like syntax. The .wait and .signal are operations on condition variables. The get() entryprocedure is correct, all the errors are in the put() entryprocedure. In the space given to the right write the correct put() entryprocedure. It should be no more than 5-6 lines of code. You are not allowed to introduce additional ordinary variables or additional condition variables.
[4] The following is an incorrect solution to the bounded buffer problem (making use of a circular buffer). We use C-like syntax. The wait and signal are operations on condition variables. The get() entryprocedure is correct, all the errors are in the put() entryprocedure. In the space given to the right write the correct put() entryprocedure. It should be no more than 5-6 lines of code. You are not allowed to introduce additional ordinary variables or additional condition variables. monitor CBuffer { int IN = 0, OUT = 0; ITEM Buf[SIZE]; conditionvar Room, NonEmpty; ITEM entryprocedure get() { if (OUT == IN) NonEmpty.wait(); res = Buf[OUT]; OUT = (OUT+1) SIZE; Room. trigger(); return res; } entryprocedure put (ITEM it) { NonEmpty.signal(); IN = (IN+1) SIZE; Buf(IN] = it; if (OUT == IN) Room.wait(); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
