The Gateway to Computer Science Excellence

#self doubt [closed]

+1 vote
66 views

A process executes the code

for( i=1; i<3; i++)

fork();

fork();

The number of new process created is ??

if explanation is on paper with diagram then it is good for me .

closed with the note: it is allready on go.
in Operating System by Active (1.8k points)
closed by | 66 views
0
0
ok i am going to close it. sorry i did't check before.
0
@shaikh masthan : brother this is indeed a different question...

we will have 3fork() calls here...
+3

the link which i provided has

for ( i = 1; i<=3; i++ )

{

   fork();

   fork();

}

 

But in this question, it seems to be

for ( i = 1; i<3; i++ )

{

   fork();

}

fork();         // Line P

 

For this question ===> after for loop, we have total 2n = 22 = 4 processes ( i=1 an i=2 but can't run at i = 3 )

but after Line P, there are 4*2 = 8 processes, in which only 1 is root call, 7 are newly created processes by fork.

0

brother this is indeed a different question...

changing the values, doesn't mean it is different question., i gave clear explanation, in that link. if some one clearly read (understood) it, they didn't feel this question is also need to answer by someone.

0
ok sure :) no problem
0
bro i got it.. ans is 15
0
How it is 15?
0
becoz there is no curly braces after loop so first fork () consider as three times and last is one so total four fork().

now for child process you can apply formula (2^N)-1
0
Did you read my previous comment?

for loop runs only 2 times ( note that it is less than symbol in condition )
0
sorry bro its my typing mistake in question.. there is equal to = symbol too.
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,364 answers
198,492 comments
105,260 users