A process executes the codefork();fork();fork();The total number of ch...
The correct answer is option 'C' - 7. Let's break down the code and analyze it step by step to understand why.
1. The initial process calls the `fork()` system call. This creates a new child process. So now we have 2 processes - the parent and the child.
2. Both the parent and child processes call `fork()` again. This means that each process will create a duplicate of itself. So now we have 4 processes - the original parent, the original child, and two new child processes created by the parent and child.
3. Finally, all 4 processes call `fork()` once more. This means that each process will create another duplicate of itself. So now we have 8 processes - the original parent, the original child, the two child processes created by the parent in the previous step, and four new child processes created by the four existing processes.
Therefore, the total number of child processes created is 7.
Let's summarize the steps:
1. Initial process: 1 process (parent)
2. After first `fork()`: 2 processes (parent and child)
3. After second `fork()`: 4 processes (original parent, original child, new child created by parent, new child created by child)
4. After third `fork()`: 8 processes (original parent, original child, 2 new children created by parent, 4 new children created by the 4 existing processes)
So the correct answer is 7 child processes.
A process executes the codefork();fork();fork();The total number of ch...
The no. of child processes created by fork() instructions is 2^n-1 where,n=No. of fork() instructionsIn above case,n=3 so No. of child processes is 2^3-1=7