StreakPeaked· Practice

ExamsGATETechnical

A process executes the code fork(); fork(); fork(); The total number of child processes created is

  1. 3
  2. 4
  3. 7
  4. 8

Correct answer: 7

Solution

Each call to fork() creates a new process, and the number of processes doubles with each fork. After three fork calls, the total number of processes is 2³ - 1 (the original process is not counted as a child), resulting in 7 child processes.

Related GATE Technical questions

⚔️ Practice GATE Technical free + battle 1v1 →