Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ code Using this Function for Producer while (true) { } /* produce an item and put in nextProduced */ while (count == BUFFER_SIZE)

In C++ code

Using this Function for Producer

while (true) {

}

/* produce an item and put in nextProduced */

while (count == BUFFER_SIZE) ; // do nothing

buffer[in] = nextProduced;in = (in + 1) % BUFFER_SIZE;

count++;

}

Using this Function for Consumer

while (true) {

while (count == 0)

; // do nothing

nextConsumed = buffer[out];out = (out + 1) % BUFFER_SIZE;

count--;

/* consume the item in nextConsumed */

}

>>>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 program will then create a 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. 7.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 clear show that you implemented subtasks using 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

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions

Question

=+ Interviews with key people. Which people?

Answered: 1 week ago

Question

What are Electrophoresis?

Answered: 1 week ago

Question

LO2 Discuss important legal areas regarding safety and health.

Answered: 1 week ago