Question
Write a multi-processed program using the fork() call which will take in parameters from the command line and calculate the sum of the numbers. In
Write a multi-processed program using the fork() call which will take in parameters from the command line and calculate the sum of the numbers. In doing so, there will be three processes. The parent process will start by setting up the necessary pipes for communication. Then, it will spawn 2 child processes (C0 and C1). The parent process will then parse the entries passed in as arguments. If the value entered is even, it will be piped to C0 to be summed. If it is odd, it will be piped to C1 to be summed. As each child process receives a number, it will add the number to the sum of numbers it has received. Once all numbers have been parsed and sent via pipes to the child processes, the parent will close the pipes to the child processes. The child processes will then write their sum in the pipes going back to the parent process and all processes will exit.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started