The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+12 votes
1.3k 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. 2n-1
  3. 2n
  4. 2n+1 - 1
asked in Operating System by Veteran (68.9k points) | 1.3k views

1 Answer

+25 votes
Best answer

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

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

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

answered by Veteran (332k points)
selected by
please elaborate.

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

32,693 questions
39,293 answers
110,109 comments
36,701 users