Answered step by step
Verified Expert Solution
Link Copied!

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 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions

Question

outline some of the current issues facing HR managers

Answered: 1 week ago