Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ .cpp In this lab you will simulate simple multithreading application with producer and consumer problem. Modify Producer and Consumer Problem from lecture note so

c++

.cpp

In this lab you will simulate simple multithreading application with "producer and consumer" problem. Modify "Producer and Consumer Problem" from lecture note so that it can use all buffer space, not "buffe_size - 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 buffer size and counter limit.

2. The main program will then create two 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. You can implement this project in any OS environment of your choice, windows, Linux, etc. Also, you can use any programming languages you want but your program and sample run should clearly show implementation of subtasks through separate threads

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

Determine the characteristics of a successful model.

Answered: 1 week ago