Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

How would you write a program in c (I know there is a similar question, but I am looking to do this in C and

How would you write a program in c (I know there is a similar question, but I am looking to do this in C and not C++) that uses fork and pipe to create processes to add up all numbers in a file. The user will enter a number (1, 2, or 4) of parallel processes to create for processing the numbers. The system will then create this many processes, evenly dividing the file contents between the processes. For example, if the file has 1000 numbers and the user wants 4 processes, then each process would process 250 numbers in the file. Parent process. This process allows user to input the number of processes to create (1, 2, or 4). It determines what portion of the file each process must work on and informs the process via a pipe. More specifically, the first child process handles the first block in the file, and the second child process handles the second one and so on. The parent then waits for each child to report its result. Once each result is received, it combines the results prints the overall result. Child process. Receive which part of the file to calculate from the parent process through pipe. Process the file and send the result back to the parent process through pipe. There are 4 given files named file1.dat, file2.dat, file3.dat, file4.dat this program should output the result and record the run time for each process 1,2, and 4

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_2

Step: 3

blur-text-image_3

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

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students explore these related Databases questions

Question

what is a pillar of finance?

Answered: 3 weeks ago

Question

omplete the following table

Answered: 3 weeks ago