4,537 views
1 votes
1 votes
int main(){
    int i;
    for(i=0;i<4;i++)
    fork();
    return 0;
}

in my calculation i think 14 processes will be created including the the parent process. am i right ? Is there any easier method to solve this kind of question ?? please provide the right approach to solve these kind of problems

2 Answers

Best answer
2 votes
2 votes

If the program have n Fork() call then it will have 2n-1 child processes 

Here n=4  therefore child process 24-1 = 15
so total process by program = child process + one main process = 15+1 =16  

1 votes
1 votes
Total 16 processes created

1 parent and  15 child

Related questions

11 votes
11 votes
8 answers
1
neha pawar asked Oct 30, 2014
9,044 views
Consider the following Pseudo codemain() { int t1=0,t2=0,t3=0; t1=fork(); t2=fork(); if(t1!=0) { t3=fork(); printf("0"); } }Find the total number of processes that will b...
1 votes
1 votes
1 answer
2
Mak Indus asked Jan 11, 2019
2,879 views
How many processes will be created when we run the below program?main ( ){Printf (“Hi”);fork ( );Printf (“Hello”);fork ( );fork ( );}(a) 3 ...