Reference no: EM132206705
Write a multithreaded program in C under the Linux operating system using the pthread API.
The program shall accept a data filename from the command line, containing the number n, and n distinct integers, one value per line.
The program shall use the above algorithm to find their maximum as described above.
Your program shall read as much values as defined by the first integer n, or until the end of the data file is reached if the number of entries is less than n.
The program shall then write the first 2 output lines, then create n threads for Step 1, then wait for all threads to finish, then write the contents of array W, then create n*(n-1)/2 threads for Step 2, then wait for all threads to finish, then write the contents of array W again, then create n threads for step 3, then wait for them to finish, then print the result and exit.
Your program shall check for all possible errors, and if there are some errors, it shall attempt to correct them by interacting with the user or terminate gracefully after printing a useful error message.