GATE - 2008 | OS | A process executes the following code for (i =0; i < n; i + +) for ( )

GATE - 2008 | OS | A process executes the following code for (i =0; i < n; i + +) for ( )
Posted on 14-02-2022

GATE - 2008 [Operating System]

Question:

A process executes the following code for (i =0; i < n; i + +) for ( ); The total number of child processes created is  

A

n

B

(2n) - 1

C

2n

D

(2n+1) - 1

    

Solution:

Option (B) is Correct.

The fork is a system call, implemented in the kernel.
It is an operation where the process creates a copy of itself.

A process executes the following code for (i =0; i < n; i + +) for ( ); The total number of child processes created is

1,3,7,15,31,... ⇒ 2n-1

Thank You