4,697 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

9.6k
views
8 answers
11 votes
neha pawar asked Oct 30, 2014
9,649 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 be created by the above program execution.
3.0k
views
1 answers
1 votes
Mak Indus asked Jan 11, 2019
3,004 views
How many processes will be created when we run the below program?main ( ){Printf ( Hi );fork ( );Printf ( Hello );fork ( );fork ( );}(a) 3 ... (d) 8
923
views
1 answers
0 votes
Na462 asked May 25, 2018
923 views
#include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(void) { pid_t pid = fork(); pid = fork(); pid = fork(); if (pid ... my solution carefully and point out weather the number of parent and child were calculated correctly ?