Question: 1) how many processes are created? including parent process #include #include int main() { int x = 1; /* fork off a child process */
1) how many processes are created? including parent process
#include#include int main() { int x = 1; /* fork off a child process */ if (fork()==0) x++; /* fork off another child process */ if (fork()==0) x++; printf("x = %d : ", x); fflush(stdout); /* wait for a signal to be received */ pause(); }
2) Which of the following outputs are possible? Select all that apply
a)x = 2 : x = 1 : x = 2 : x = 2 :
b)x = 2 : x = 2 : x = 2 :
c)x = 1 : x = 2 : x = 3 : x = 3 :
d)x = 1 : x = 2 : x = 2 :
e)x = 1 :
f)x = 3 : x = 2 : x = 1 : x = 2 :
g)x = 3 : x = 2 : x = 1 :
h)x = 1 : x = 2 : x = 2 : x = 3 :
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
