Question: Your program should perform an operating system API call to open a text file named Data.txt , write 1 , 0 0 0 , 0

Your program should perform an operating system API call to open a text file named Data.txt, write 1,000,000 random
numbers in the range [0..100] to the file, and close the file. Next, the program creates three threads. Each thread should:
1. Perform an operating system API call to open the Data.txt file.
2. Create a file named Data_Thread_X.txt, where X is the letter A, B, or C, depending on which thread created the file.
3. Each thread copies the data from the Data.txt file to its Data_Thread_X.txt file.
4. While copying the data, calculate the average of the numbers in the Data.txt file to two places past the decimal
point (e.g.,50.00) and output the average just before the thread finishes. Make sure this works on files of any size.
5. Close the Data.txt file and the Data_Thread_X.txt files.
6. Compute each threads execution time and output it in milliseconds (ms).
7. The main thread should wait for the thread tasks to finish. The main thread should also compute the total wall
clock execution time (ms) of the program execution (including all three thread tasks) and output the result.
8. Be sure it is clear which thread is outputting which information in #4, #6, and #7 above

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!