Question: This program should use the fork() instruction to create 1, 2 or 3 children. If the parent creates just a child, the parent will send

 This program should use the fork() instruction to create 1, 2or 3 children. If the parent creates just a child, the parent

This program should use the fork() instruction to create 1, 2 or 3 children. If the parent creates just a child, the parent will send the array to the child. The child will receive the array and it will add its elements. Then the child will send the summation to the parent who will print that summation. Now if the parent creates two children, it will send the first half of the array to one child and the second half to the another one. Each child will receive the corresponding half of the array, and it will compute its sum. Each child will send the partial sums to the parent who will collect and add the partial results. Finally, the parent will print the final sum. (Note: Use arrays of even length). Gift: At the end of the document you will find a gift, you can use it and grow the program to two and three kids !!! Program format and expected output: Here, some examples: Example 1 luis12 5 3 1089 Here, the parent (luis) creates just a child (first parameter with the red square) The next elements in the command line correspond to elements of the array (2,5, 3, 10, 8, 9). Example 2 /luis 3 1 2 3 4 5 6 Here, the parent (luis) create three children. The next elements in the command line correspond to elements of the array (1, 2, 3, 4, 5, 6). Expected outputs Example 1 luis 1 1 2 3 4 5 6 Assuming parent has pid 2, and child 1 has pid: 3. We want to see the following output >>I am parent with pid: 2 sending the array: 1 2 3 4 5 6 to child with id: 3. >>I am child with pid: 3, adding the array 1 2 3 4 5 6 and sending partial sum 21. >>I am the parent pid: 2 receiving partial sum 21 and printing 21. Example 2 Sluis 2 1 2 3 4 5 6 Assuming parent has pid 2, child 1 has pid: 3, and child 2 has pid: 4. >>I am parent with pid: 2 sending the array: 1 2 3 to child with pid 3, and 4 5 6 to child with pid 4. >I am child with pid: 3, adding the array 1 2 3 and sending partial sum 6. >>I am the parent pid: 4, adding the array 4 5 6 and sending partial sum 15. >>I am the parent pid: 2 receiving partial sum 6 and 15 and printing 21. Example 3 luis 3 1 2 3 4 5 6 Assuming parent has pid 2, child 1 has pid: 3, child 2 has pid: 4, and child 3 has pid: 5 >>I am parent with pid: 2 sending the array: 1 2 to child with pid 3, 4 5 to child with pid 4, and 56 to child with pid 5 This program should use the fork() instruction to create 1, 2 or 3 children. If the parent creates just a child, the parent will send the array to the child. The child will receive the array and it will add its elements. Then the child will send the summation to the parent who will print that summation. Now if the parent creates two children, it will send the first half of the array to one child and the second half to the another one. Each child will receive the corresponding half of the array, and it will compute its sum. Each child will send the partial sums to the parent who will collect and add the partial results. Finally, the parent will print the final sum. (Note: Use arrays of even length). Gift: At the end of the document you will find a gift, you can use it and grow the program to two and three kids !!! Program format and expected output: Here, some examples: Example 1 luis12 5 3 1089 Here, the parent (luis) creates just a child (first parameter with the red square) The next elements in the command line correspond to elements of the array (2,5, 3, 10, 8, 9). Example 2 /luis 3 1 2 3 4 5 6 Here, the parent (luis) create three children. The next elements in the command line correspond to elements of the array (1, 2, 3, 4, 5, 6). Expected outputs Example 1 luis 1 1 2 3 4 5 6 Assuming parent has pid 2, and child 1 has pid: 3. We want to see the following output >>I am parent with pid: 2 sending the array: 1 2 3 4 5 6 to child with id: 3. >>I am child with pid: 3, adding the array 1 2 3 4 5 6 and sending partial sum 21. >>I am the parent pid: 2 receiving partial sum 21 and printing 21. Example 2 Sluis 2 1 2 3 4 5 6 Assuming parent has pid 2, child 1 has pid: 3, and child 2 has pid: 4. >>I am parent with pid: 2 sending the array: 1 2 3 to child with pid 3, and 4 5 6 to child with pid 4. >I am child with pid: 3, adding the array 1 2 3 and sending partial sum 6. >>I am the parent pid: 4, adding the array 4 5 6 and sending partial sum 15. >>I am the parent pid: 2 receiving partial sum 6 and 15 and printing 21. Example 3 luis 3 1 2 3 4 5 6 Assuming parent has pid 2, child 1 has pid: 3, child 2 has pid: 4, and child 3 has pid: 5 >>I am parent with pid: 2 sending the array: 1 2 to child with pid 3, 4 5 to child with pid 4, and 56 to child with pid 5

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!