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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!