Value of i
|
fork calling
|
0
|
Called
|
1
|
not called
|
2
|
Called
|
3
|
not called
|
4
|
Called
|
5
|
not called
|
6
|
Called
|
7
|
not called
|
8
|
Called
|
9
|
not called
|
From the table it is clear that fork is called 5 times
Formula:
If n times fork is called the number of child processes created = 2n - 1
Since n = 5 in the given code then number of child processes created = 25 - 1 = 31