search
Log In
0 votes
131 views
Can Anyone Explain clearly

process

{

 fork();

fork();

fork();

}

what are the number of childs?
in Operating System 131 views

2 Answers

0 votes
 
Best answer

7.

First fork() will generate 1 children. Total number of process = 1 child (C1) + 1 parent (P) = 2.

Second fork() will generate 1 more process in C1 (C2) and one more process in P (C3), Total number of child processes at this stage = 3.

Similarly, 4 more child processes will be generated after calling third fork().

So, overall 8 processes will be there, 1 parent and 7 children. For more information, you can refer to the link provided to you in response to your another similar question .


selected by
0 votes

Answer is 7

Bcz when we execute fork() command then a child process is created and then the next instruction following this fork() command will be executed by both parent as well as by the child process.

First fork() will generate 1 children. Total number of process = 1 child (C1) + 1 parent (P) = 2.

Second fork() will generate 1 more process in C1 (C2) and one more process in P (C3), Total number of child processes at this stage = 3.

Similarly, 4 more child processes will be generated after calling third fork().

So, overall 8 processes will be there, 1 parent and 7 children.

Related questions

0 votes
0 answers
1
493 views
In a Binary Tree with N nodes,every node has an odd number of descendants. Every node is considered to be its own descendant. What is the number of nodes in the tree that have exactly one child? A) 0 B) 1 C) (n-1)/2 D) (n-1)
asked Jul 29, 2016 in DS smartmeet 493 views
0 votes
1 answer
3
760 views
In a binary tree with n nodes every node has an odd no. of descendants. Every node is considered to be its own descendant. What is the no. of nodes in the tree that has exactly one child? (a) 0 (b) 1 (c) (n-1)/ 2 (d) n-1
asked Sep 28, 2015 in Programming IgnitorSandeep 760 views
...