The Gateway to Computer Science Excellence
0 votes
97 views
Can Anyone Explain clearly

process

{

 fork();

fork();

fork();

}

what are the number of childs?
in Operating System by Boss (13.9k points) | 97 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 .

by Active (2.6k points)
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.

by Active (3.3k points)
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,292 answers
198,236 comments
104,919 users