Question: (Question 9) Shown below partially implements thread-safe blocking bounded queue (BBQ): const int MAX = 10; class BBQ{ Lock lock; CV full; CV empty; int

(Question 9) Shown below partially implements thread-safe blocking bounded queue (BBQ): const int MAX = 10; class BBQ{ Lock lock; CV full; CV empty; int buf[MAX]; int head; int tail; public: BBQO; ~BBQO {}; void insert(int item); int remove(); }; BBQ:: BBQ { head = tail = 0; int BBQ:: remove() int item; lock.acquire; while (head == tail) { empty.wait(&lock); item = buf[head % MAX]; head++; full.signal(); lock. release ; return item; 9. (7 points) Implement BBQ::insert() by filling out blank between mutex lock/unlock void BBQ:: insert(int item) lock.acquire(); { lock.release(); (Question 9) Shown below partially implements thread-safe blocking bounded queue (BBQ): const int MAX = 10; class BBQ{ Lock lock; CV full; CV empty; int buf[MAX]; int head; int tail; public: BBQO; ~BBQO {}; void insert(int item); int remove(); }; BBQ:: BBQ { head = tail = 0; int BBQ:: remove() int item; lock.acquire; while (head == tail) { empty.wait(&lock); item = buf[head % MAX]; head++; full.signal(); lock. release ; return item; 9. (7 points) Implement BBQ::insert() by filling out blank between mutex lock/unlock void BBQ:: insert(int item) lock.acquire(); { lock.release()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
