Design an algorithm for a bounded-buffer monitor in which the buffers (portions) are embedded within the monitor itself."
1 answer:
Answer:
Required code is given below:
Explanation:
monitor bounded buffer {
int items[MAX ITEMS];
int numItems = 0;
condition full, empty;
void produce(int v)
{
while (numItems == MAX ITEMS) full.wait();
items[numItems++] = v;
empty.signal();
}
int consume()
{
int retVal;
while (numItems == 0) empty.wait();
retVal = items[--numItems];
full.signal();
return retVal;
}
}
You might be interested in
I think the answer is B: parameter
What does that even mean? is this a poem?
Answer:
def insSort(arr):
ct=0;
for i in range(1, len(arr)):
key = arr[i]
j = i-1
while j >=0 and key < arr[j] :
arr[j+1] = arr[j]
j -= 1
ct=ct+1;
arr[j+1] = key
return arr,ct;
print(insSort([2,1]))
Output of the program is also attached.
23 bits would leave room for 512 node numbers.