Skip to content
Official PYQ · 2012

GATE CS 2012 Q8 — System Calls

Explain with AI

A process executes the code

fork();
fork();
fork();

The total number of child processes created is

Choose one option
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 11 parent process, the number of processes doubles with each fork() call:

  • Initially: 11 process (the parent)
  • After the 1st1^{\text{st}} fork(): 21=22^1 = 2 processes
  • After the 2nd2^{\text{nd}} fork(): 22=42^2 = 4 processes
  • After the 3rd3^{\text{rd}} fork(): 23=82^3 = 8 processes

In general, after nn consecutive fork() calls, the total number of processes is 2n2^n.

The question asks for the total number of child processes created:

Number of child processes=Total processes−Original parent process\text{Number of child processes} = \text{Total processes} - \text{Original parent process}Number of child processes=23−1=8−1=7\text{Number of child processes} = 2^3 - 1 = 8 - 1 = 7

Hence, the correct option is C.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore System Calls questions