@Ankit fork is a system call which generates new thread of execution,and returns pid of newly created thread to parent process and a value of 0 to child process.so here in second statement when fork is called 0 will be returned for child processes so they will not execute second fork in this call.so,doing in the same way you will get 20 as total no of processes created.
20
ReplyDelete@above you are right..:)
ReplyDelete@priyaranjan could you please explain the logic?
ReplyDelete@Ankit fork is a system call which generates new thread of execution,and returns pid of newly created thread to parent process and a value of 0 to child process.so here in second statement when fork is called 0 will be returned for child processes so they will not execute second fork in this call.so,doing in the same way you will get 20 as total no of processes created.
ReplyDeletehttp://www.csl.mtu.edu/cs4411/www/NOTES/process/fork/create.html
ReplyDelete