The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+14 votes
1.9k views

A process executes the following code

for(i=0; i<n; i++) fork();

The total number of child processes created is

  1. $n$
  2. $2^n-1$
  3. $2^n$
  4. $2^{n+1} - 1$
asked in Operating System by Veteran (59.6k points)
edited by | 1.9k views

1 Answer

+27 votes
Best answer

Each fork() creates a child which start executing from that point onward. So, number of child processes created will be $2^n - 1$.

At each fork, the number of processes doubles like from $1 - 2- 4 - 8 ... 2^n$. Of these except $1$, all are child processes.

Reference: https://gateoverflow.in/3707/gate2004-it_64

answered by Veteran (363k points)
edited by
–1
please elaborate.
0

At each fork, the number of processes doubles like from 1 - 2- 4 - 8 ... 2n. Of these except 1, all are child processes. 

Answer:

Related questions



Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

42,575 questions
48,566 answers
155,470 comments
63,593 users