The decrease count() function in the previous exercise currently returns 0 if sufficient resources are available and

Question:

The decrease count() function in the previous exercise currently returns 0 if sufficient resources are available and -1 otherwise. This leads to awkward programming for a process that wishes obtain a number of resources:
while (decrease count(count) == -1)
;
Rewrite the resource-manager code segment using a monitor and condition variables so that the decrease count() function suspends the process until sufficient resources are available. This will allow a process to invoke decrease count() by simply calling
decrease count(count);
The process will only return from this function call when sufficient resources are available.
Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: