Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Make a C/C++ or Java program with two processes, a producer and a consumer. If you want to use another language, clear it with me
Make a C/C++ or Java program with two processes, a producer and a consumer. If you want to use another language, clear it with me first. The producer process consists of a loop that writes the loop count (a value from 0 to 4) into a variable that it shares with the consumer process (this variable is to be initialized to 100). On each pass through the loop, before the producer writes into the shared variable, it does a random wait of from one to three seconds (compute a new random wait value on each pass through the loop). The loop is to be executed five times The consumer process consists of a loop that reads the variable it shares with the producer five times and computes the sum of the values it has read. On each pass through the loop before it reads the shared variable, it does a random wait of from one to three seconds (compute a new random value on each pass through the loop). When the loop finishes, the program is to write the sum into a file. You must run the program twice. Note that the output from the runs will almost certainly be different if you have written your program correctly. E-mail the source code, a copy of the output from each of your runs for grading (the output file must be to a data file and not a screen shot) to me. Also send me a word or text file with your observations on the assignment: What did you notice about the runs? What if anything did vou learn doing this assignment? Roughly how long (in hours) did the assignment take? Please put comments at the top of your program with your name, the date, the assignment number, and a brief description of the program. I also want to see comments within the program. The first items in your data file and observations file must be your name and the assignment number (have your program output this information into your output file). Note, I do not want screen shots, your program must output to a data file which is to be sent to me. You may zip your files together, but do not send me a tar file or another type of compression file or place the files out on the Internet or the Cloud for me to pick If you do not know how to create a process in Java or C/C++ or do not know how to do a random wait, or how to output to a data file, it is your responsibility to learn how. This information is available on the Internet. The contents of you output file should look something like this (where ### is your computed sum)
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