1 votes 1 votes Assume that a certain process executes the following code segment. for (i =0, i <=8, i++ ) fork() ; The number of new processes created is _______ Operating System tbb-os-2 numerical-answers + – Bikram asked Dec 26, 2016 • edited Nov 19, 2018 by go_editor Bikram 535 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
1 votes 1 votes Here fork is called 9 times, hence number of child process created is (2^9 - 1) = 512 -1= 511 Bikram answered Dec 26, 2016 Bikram comment Share Follow See all 8 Comments See all 8 8 Comments reply Pranav Kant Gaur commented Dec 30, 2016 reply Follow Share Would you please point me to a resource which proves that n calls to fork()(in a for statement) will result in $2^n - 1$ child process. 2 votes 2 votes Bikram commented Dec 30, 2016 reply Follow Share This one , think it is like a Binary Tree :) https://www.quora.com/If-fork-system-call-is-called-n-times-then-how-many-childs-are-created read this article must http://www.geeksforgeeks.org/fork-and-binary-tree/ 1 votes 1 votes reena_kandari commented Jan 3, 2017 reply Follow Share @Bikram sir, As we know that after fork() system call both processess(parent and child) continue execution at the instruction after the fork system call.so I thought that after fork() there is no line to execute and did wrong. It means in fork() for (i =0, i <2, i++ ) fork() ; and fork(); fork(); will be execute same...please varify 0 votes 0 votes Bikram commented Jan 3, 2017 reply Follow Share No , it is not like that extra fork() call 2 times. i mention why this answer came, read given two links. 1 votes 1 votes bad_engineer commented Jan 21, 2017 reply Follow Share The number of child process is 511 but total process created should be 512(including parent process) Why parent process is not included??? 0 votes 0 votes Bikram commented Jan 21, 2017 reply Follow Share @bad use this formula here 2n - 1 and subtract 1 for root node. think it like a full binary tree. read https://www.quora.com/If-fork-system-call-is-called-n-times-then-how-many-childs-are-created 0 votes 0 votes bad_engineer commented Jan 21, 2017 reply Follow Share I meant the question doesn't say child process it says new process so why root node(parent node) is not inlcuded??? 0 votes 0 votes Bikram commented Jan 21, 2017 reply Follow Share new process means child process , if not stated. It is taken this way only. 0 votes 0 votes Please log in or register to add a comment.