in Operating System
1,313 views
2 votes
2 votes
Consider the following code:

void main(){

For(int k=1;k<=5;k++){

pid[k]=fork();

}

In the given code all fork() statement executed successfully and all pid variables initialized to 0.What will be the total no of processes created by the above code?

A.1

B.5

C.16

D.32
in Operating System
1.3k views

4 Comments

 

fork only applies on children every time not on parent node . i hope u got point

0
0
No I didn't isn't the above code same as-

void main()

{

fork();

fork();

fork();

fork();

fork();

}

Please explain in detail :(
0
0

@Soumya Tiwari you sure the answer's 5 cuz, it should be 32 according to the given code and even according to the five forks you wrote (1 parent plus 31 child processes) Here is the code!

https://onlinegdb.com/B1dK3n0yE

1
1

Please log in or register to answer this question.

Related questions