devvapp
devvapp

Reputation: 143

Fork(System call) - Number of process

I'm new to system calls. Here is my question. If segment_A creates 'n' processes. How many number of processes in total are created by the following code.

fork();
segment_A

My guess is '2n+2' processes including the child and parent processes. Please shed some light on this. Its really confusing to understand fork system call.

Thanks in advance.

Upvotes: 0

Views: 233

Answers (2)

Bharti Soni
Bharti Soni

Reputation: 19

fork creates another process so after fork system call there will be two process and each of the process will create "n" new processes. So there will be 2(n+1) = 2n + 2 processes and 2n + 1 processes will be created by the code segment.

Upvotes: 2

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798626

The parent process has already been created. fork() creates a single additional process, and each process then creates n processes.

Upvotes: 2

Related Questions