Question
I've got to implement the code in the attached image using only C++'s threads, mutexes, and condition_variable libraries. I am pretty lost as to where
I've got to implement the code in the attached image using only C++'s threads, mutexes, and condition_variable libraries. I am pretty lost as to where to start as I don't fully understand C++ threads, mutexes, or condition variables and would appreciate some help on this. It does have to be able to do a few of the following things as well, which I will list below:
Use a char array of size N as the shared buffer.
Producer should randomly generate ( >N ) uppercase letters and insert them into the next available space in the buffer, then print out the letter in lowercase form to standard output.
The consumer should consume the uppercase characters from the buffer and print them out unchanged to standard output.
The main function should wait a short amount of time to give the producer time to partially fill the buffer before beginning the consumer thread.
The producer and consumer threads must only access one element at a time. Do not add or remove multiple items within the critical section.
#include
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started