Question: 8 / / Define buffer and condition variables ` ` ` Then include declarations for the mutex, condition variables, and other variables. ` ` `
Define buffer and condition variables
Then include declarations for the mutex, condition variables, and other variables.
Define buffer and condition variables
#define BUFFERSIZE
int bufferBUFFERSIZE;
int count ; How many things are in the buffer
pthreadmutext mutex; A mutex lock
pthreadcondt notfull; A condition variable for a notfull buffer
p pthreadcondt notempty; A condition variable for a notempty buffer
Define the number of items to produceconsume
and the number of producerconsumer pairs
int NUMTHREADPAIRS ;
int NUMITEMS ;
Define the time it takes to produce and consume items
int PRODUCETIME ;
int CONSUMETIME ;
For simplicity, this program is set up so there are the same number of producers as consumers.
Currently, it takes twice as long to consume an item as it does to produce an item. We'll be changing this later.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
