11,825 views
41 votes
41 votes

A process executes the following segment of code :

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


The number of new processes created is

  1. $n$
  2. $((n(n + 1))/2)$
  3. $2^n - 1$
  4. $3^n - 1$

6 Answers

0 votes
0 votes

For some people who get confused without proper visual representation as to how no. of children are doubling at each level, this tree should help you out.

Interpretation: Main process on calling its first fork, creates a child process ”1”, and now both main and child “1” have 2 forks() in them. Therefore the 2nd level in the tree is representing the two processes that are active after the 1st fork. Notice that only one child is created by the first fork, which is marked by a square box. Total square boxes are doubling at each level, as shown by the figure to the right of the tree.

I hope this helps

Answer:

Related questions

27 votes
27 votes
4 answers
1
Ishrat Jahan asked Nov 1, 2014
13,812 views
Which one of the following is NOT shared by the threads of the same process ?StackAddress SpaceFile Descriptor TableMessage Queue
15 votes
15 votes
2 answers
2
23 votes
23 votes
4 answers
4
Ishrat Jahan asked Nov 2, 2014
4,857 views
Which one of the following binary trees has its inorder and preorder traversals as $BCAD$ and $ABCD$, respectively?