Question: Please help me with this program, I'm stuck! Create a program in C/C++ with a circular buffer where NextIn and NextOut are indexes showing where
Please help me with this program, I'm stuck!
Create a program in C/C++ with a circular buffer where NextIn and NextOut are indexes showing where to insert and extract items. Use two conditional variables empty and full to indicate whether the shared buffer is empty or full. The producer signals full when an item is inserted and consumer signals empty. Program must have 8 Pthreads (4 producers and 4 consumers), each of which calculate local min, max, and average of items received. A producer makes 10 items using a random number generator seeded with its ID and adds it to the buffer, where it is read from in the consumer. NumItems is given when compiling in argv, and each thread produces/consumes exactly NumItems. Parent reports the overall min, max, and average. Must use lock/unlock and signalling to synchronze threads. Program runs in linux using pthread.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
