A process executes the code
fork(); fork(); fork();
The total number of child processes created is
View worked solution
Answer: C
When a process executes a fork() system call, it creates a duplicate child process. Both the parent and the child processes continue execution from the next instruction.
If we start with parent process, the number of processes doubles with each fork() call:
- Initially: process (the parent)
- After the
fork(): processes - After the
fork(): processes - After the
fork(): processes
In general, after consecutive fork() calls, the total number of processes is .
The question asks for the total number of child processes created:
Hence, the correct option is C.
Free practice · Your answers on this page are not saved.
