• closed by
2,608 views
1 1 vote
closed as a duplicate of: fork() system call.

What is the number of child process created ?

Answer given was 63, BUT i am getting 9 !

2 Answers

0 0 votes

Here's a rough explanation,

In the above figure, you can see that after every fork() there is a formation of 2 processes. And at the end we can also see that there are a total of 64 processes. But the process that started this whole chain is the first one(which is also the only supreme parent to all these children).

So we conclude that 26 - 1 = No. of children of the process.

0 0 votes

During 1st iteration (i=0), there is 2 fork() calls so there will be 4 processes.

In the 2nd iteration (i=1), those 4 processes will execute 2 fork() calls i.e. 4 processes, so there will be 4*4 processes i.e. 16.

Similarly, in the 3rd iteration (i=2), those 16 processes will execute 2 fork() calls i.e. 4 processes, so there will be 16*4 = 64 processes.

Now the question is asking for number of child processes, so 64 – 1 = 63.

Hence the answer is 63 child processes.

Position:
Show:

Related questions

3 3 votes
1 answers 1 answer
3.9k
3.9k views
0 0 votes
2 2 answers
2.0k
2.0k views
Overflow04 asked Aug 29, 2022
2,027 views
On Solving manually I too getting 14 as answer. but on running more than 14 * are printed.
0 0 votes
2 2 answers
1.7k
1.7k views
Erwin Smith asked Apr 11, 2023
1,720 views
void main() { int n = 1; if(fork()==0) { n = n<<1; printf(“%d, “, n); n = n <<1; } if(fork()==0) n=n+700; printf(“%d, “,n); }Which of the following output is not possible...
3 3 votes
1 1 answer
2.9k
2.9k views
indrajeet asked Nov 20, 2016
2,920 views
MY QUESTION IS1)WHY PRINTF() PRINT VIRTUAL ADDRESS(MENTIONED IN EXPLANTION) NOT PHYSICAL ADDRESS2) WHY VIRTUAL ADDRESS(O/P OF PRINTF(&VAR)) OF A VARIABLE CHANGES WHEN WE ...