Question: Lloyd 3302 -You will need to write a single file of source code in C++. 1. You will need to have a Command line argument
Lloyd 3302
-You will need to write a single file of source code in C++.
1. You will need to have a Command line argument that tells the program how many children processes it needs to spawn.
Please note the format for this argument should be like this:
-You will need to keep track of the PIDs of all the children. As such you will need to create an array to store these values inside.
Two functions to be run. A parent function and a child function. These functions are to be run based on which process is the one calling it.
The child function should create a new counting loop (much like the example in class) and count 10 times. It should print out the PID of the child as well as the current value of the counter.
The parent function needs to perform 2 different tasks.
It needs to wait until all of the children processes are complete
Once all children process are complete, it should display a message showing all of the child processes then a message saying that the program has completed.
The parent process ONLY should create the number of children specified by the command line. DO NOT let the children spawn processes (this will result in unwanted processes being created).
You need to call the appropriate function based on which process is running after all fork calls have been currently made.
Let me know if you have any questions!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
