subject

Implement a solution to the producer consumer problem with the following settings (write c++ code):
there are three producers all in infinite while loops each producing 1 item in one loop.
there are three consumers all in infinite while loops each consuming 1 item in one loop.
every consumer or producer yields at the end of a loop to the next process
consider that the buffer size is 6 items.
consider that in your ready queue there are three consumers then seven producers then 7 consumers and finally three more producers .
run the code for infinitely long.
at the end of each loop before yield the consumer should print the following:
if consumer x is consuming an item then print
"this is consumer x consuming item generated by producer y"
else print
"consumer x is waiting"
at the end of each loop before yield the producer should print the following: if producer x is producing an item then print
"this is producing x producing item number y"
else print
"producer x is waiting"

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 12:00
Which of the following ā€œinvisibleā€ marks represents an inserted tab?
Answers: 1
question
Computers and Technology, 23.06.2019 02:50
Thereā€™s only one game mode that stars with the letter ā€˜eā€™ in cs: go. which of the options below is it?
Answers: 1
question
Computers and Technology, 23.06.2019 19:00
This question involves a class named textfile that represents a text file. public class textfile { private string filename; private string filename; private arraylist words; // constructors not shown // postcondition: returns the number of bytes in this file public int filesize() { } // precondition: 0 < = index < words.size() // postcondition: removes numwords words from the words arraylist beginning at // index. public void deletewords(int index, int numwords) { } // precondition: 0 < = index < = words.size() // postcondition: adds elements from newwords array to words arraylist beginning // at index. pub lic voidaddwords(int index, string[] newwords) { } // other methods not shown } complete the filesize() method. the filesize() is computed in bytes. in a text file, each character in each word counts as one byte. in addition, there is a space in between each word in the words arraylist, and each of those spaces also counts as one byte. for example, suppose the words arraylist stores the following words: { mary had a little lamb; its fleece was white as snow. } the filesize() method would compute 4 + 3 + 1 + 6 + 5 + 4 + 6 + 3 + 5 + 2 + 5 as the sum of the lengths of each string in the arraylist. the value returned would be this sum plus 10, because there would also be 10 spaces in between the 11 words. complete the filesize() method below: // postcondition: returns the number of bytes in this file public int filesize() { }
Answers: 1
question
Computers and Technology, 23.06.2019 19:40
Use a physical stopwatch to record the length of time it takes to run the program. calculate the difference obtained by calls to the method system.currenttimemillis() just before the start of the algorithm and just after the end of the algorithm. calculate the difference obtained by calls to the method system.currenttimemillis() at the start of the program and at the end of the program so that the elapsed time includes the display of the result. use the value returned by the method system.currenttimemillis() just after the end of the algorithm as the elapsed time.
Answers: 3
You know the right answer?
Implement a solution to the producer consumer problem with the following settings (write c++ code):...
Questions
question
Mathematics, 31.07.2019 13:50
question
Mathematics, 31.07.2019 13:50