You will write a program that uses multiple processes to compute the sum of a set of (small) positive integers using pipes
There are two types of processes for this homework:
I). A set of “slaves” processes: Each slave process gets two small integers from itsargv, computes its sum and returns the result using the exit system call. So, a slave process is created for every sum.
II) A “master”process: This process is responsible for creating the slave processes, and coordinating the computation. Note that all the computation is done by the “slave” processes. All the numbers are provided in the command lineargv.Themasterprocess also set a timer at the start of computation to 3 seconds. If the computation has not been finished by this time, themaster processkills all the slaves and then exits. You should print an appropriate message(s) in this case. Note that themasterprocess may have to create multiple sets ofslaveprocesses. For example, if there are 8 numbers to be added, then themasterprocess will first create 4slavesand get the result from them. At this point there are 4 numbers, and it creates 2.
slaves. Finally one slave is created to compute the overall sum. To make it simpler, if the number of integers to add is odd, themasteradds a 0 to the list of numbers. This may happen at any step during the computation. The code formasterprocess should be compiled separately and its executable code should be calledmaster.The executable code for theslaveprocess should be calledslave. So, to compute the sum of the numbers 1 through 7, the command line will look like
master 1 2 3 4 5 6 7
Since the results are passed around byexitsystem call, keep the numbers small (single digit). Eachslaveprocess prints its process id, its operands, and their sum. Each time themastergets a result from a slave, it prints the pid of the slave and the partial sum.
Test your programs for the following cases:
master 1
master 1 2 3 4 5
master 1 2 3 4 5 6 7 8





