Consider the following program. main() { fork(); fork(); fork(); } How many…
2015
Consider the following program. main() { fork(); fork(); fork(); } How many new processes will be created?
- A.
8
- B.
6
- C.
7
- D.
5
Attempted by 611 students.
Show answer & explanation
Correct answer: C
Each fork() call doubles the number of processes. Starting with 1 process, after three forks: 2^3 = 8 total processes. Subtracting the original process gives 7 new processes created.
A video solution is available for this question — log in and enroll to watch it.