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
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