Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 random
numbers in the range to the file, and close the file. Next, the program creates three threads. Each thread should:
Perform an operating system API call to open the Data.txt file.
Create a file named DataThreadXtxt where X is the letter A B or C depending on which thread created the file.
Each thread copies the data from the Data.txt file to its DataThreadXtxt file.
While copying the data, calculate the average of the numbers in the Data.txt file to two places past the decimal
point eg and output the average just before the thread finishes. Make sure this works on files of any size.
Close the Data.txt file and the DataThreadXtxt files.
Compute each threads execution time and output it in milliseconds ms
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.
Be sure it is clear which thread is outputting which information in # # and # above
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