The Gateway to Computer Science Excellence
+7 votes
2.2k views

Consider the following program.

main()
{
    fork();
    fork();
    fork();
}

How many new processes will be created?

  1. 8
  2. 6
  3. 7
  4. 5
in Operating System by Veteran (106k points) | 2.2k views

2 Answers

+15 votes
Best answer
No of child process created by $n$ fork calls in series =$2^{n}-1$

With 3 three fork process =7

Option C is correct.
by Boss (38.7k points)
selected by
+1
new processes are 7 but total processes are 8 ryt?
0
yes.
0
@ManojK,

 Please draw the tree for fork() call, iam getting 8 child process when iam drawing tree of all fork() calls.

Thank You.
+1 vote
If a program has N series of fork call then total number of processes(including parent process) will be created = 2^N.

total number of child processes(New processes) = 2^N - 1

According to our Question, N=3

New processes = 2 ^3 - 1

                       = 7 processes
by Boss (42.5k points)
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
50,737 questions
57,391 answers
198,591 comments
105,442 users