Question: I need to creatre a C++ program that can modify the producer and consumer. My main programmig language is C++. Modify Producer and Consumer Problem

I need to creatre a C++ program that can modify the producer and consumer. My main programmig language is C++.

Modify "Producer and Consumer Problem" from lecture note so that it can use all buffer space, not "buffersize 1" as in the lecture note. This program should work as follows:

1. The user will run the program and will enter two numbers on the command line. Those numbers will be used for buffersize and counter limit.

2. The main program will then create separate threads, producer and consumer thread.

3. Producer thread generates a random number through random number generator function and inserts this into buffer and prints the number. Increment counter.

4. Consumer thread goes to the buffer and takes a number in the proper order and prints it out. Increment counter.

5. After counter reaches its limit, both threads should be terminated and return to main.

6. Main program terminates

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!