Question: (20 points) Consider the following program. Assume fork calls are successful, the original process has id 100, and that new processes ids start at

(20 points) Consider the following program. Assume fork calls are successful, the original process has id 100, and that new processes ids start at 101 with increments of one. The parent of the original process has id 50. Note: getpid() returns the id of the executing process and getppid() returns the id of the parent of the executing process. int main (int argc, char *argv[]) { int i, a, pid; a = 1; for (i=0; i < 3; ++i) { a = a*2; pid = fork(); if (pid == 0) { a = a+1; } else cout < < "A: " < < a < < ", " < < getpid() < < ", < < getppid() < < endl; { wait (NULL); cout < < "B: " < < a < < ", " < < getpid() < < ", " < < getppid() < < endl; } } return (0); } What will be printed when the program executes (that is, give the output)?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
