Question: Write a multi threaded Linux program that counts up all the numbers found in three separate files all at the same time. The program will

Write a multi threaded Linux program that counts up all the numbers found in three separate files all at the same time.

The program will require 4 threads:

• The main thread - Creates three child threads and assigns the names of the files to each child thread. Once each child thread is finished, it will print the total of all three files to the screen once the children are done processing them.

• Child thread - Each thread is given the name of a file to process. They will add up all the numbers in their assigned file and report the total back to main. Use the system calls you learned earlier to interact with the files (open, read, close). Use the POSIX library to manage the multithreading. Use the attached files with your program. Use the attached files to test your program, one file per child thread.

numbers2.txt

numbers1.txt

numbers3.txt

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Writing a multithreaded program requires the use of the pthreads library in Linux Ill provide you with a simple C program that reads numbers from thre... View full answer

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 Operating System Questions!