A process executes the following code
for(i=0; i<n; i++) fork();
The total number of child processes created is
GATE CSE 2008Operating System › Process Concepts, Threads & System CallsVerified
(B) 2 n − 1 2^n-1 2 n − 1
Trace the loop as a process-creation tree. In every iteration of the for loop, every process currently in the system executes fork(). Thus the number of processes doubles after each iteration: starting with 1 process, after n iterations there are $2^n$ processes in total. Exactly one of these is the original parent, and all the rest are child processes (descendants), so the number of child processes is $2^n - 1$.
Each fork() call doubles the number of processes because both the parent and the newly created child continue executing the same loop. After n iterations there are $2^n$ processes total. Since exactly one process is the original parent and all others are children, the number of child processes is $2^n - 1$. Therefore option B is correct.
Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.