Question: Answer the following questions about the code: .( Assuming that fork() call completes successfully). #include #include #include int count = 0; main() pid_t x; x
Answer the following questions about the code: .( Assuming that fork() call completes successfully).
#include
#include
#include
int count = 0;
main()
pid_t x;
x = fork();
count = count + 5;
printf(A: count is %d ,count); /* Line L */
if (x == 0) {
count = count + 10;
fork();
printf(B: count is %d ,count); /* Line M */
}
else {
count = count + 15;
printf(C: count is %d ,count); /* Line N */
}
}
Questions:
a) What is the value of count at the line marked by Line L, Line M, and Line N? Be specific
b) How many processes are created during the execution of this program (including the parent process)?
c) Assume the program runs to the end without error. List at least four output sequences that are NOT possible for the program above. Each sequence should consist of the accurate number of the output..
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
