Question
Make a C / C++, Java, or Python program with two processes (or threads, whichever is easier for you to code), a producer and a
Make a C / C++, Java, or Python program with two processes (or threads, whichever is easier for you to code), a producer and a consumer. If you want to use another language, clear it with me first. The producer process/thread 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/thread (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 and submit the output from both runs. Note that the output from the runs will almost certainly be different if you have written your program correctly. Place a zip file with the 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) in the D2L Dropbox for the 2nd assignment. Also include a word or text file with your observations on the assignment: What did you notice about the runs? What if anything did you 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 are to zip your files together and place the zip file in the drop box for assignment 2 on D2L - 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 up. If you do not know how to create a process/thread in Java, C/C++, or Python 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). If you have the output from both runs in the same file, you do not need to repeat your name and the assignment number. John Smith Computer Operating Systems Assignment #2 The sum is ###
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