24 votes 24 votes The following C program is executed on a Unix/Linux system : #include<unistd.h> int main() { int i; for(i=0; i<10; i++) if(i%2 == 0) fork(); return 0; } The total number of child processes created is ________________ . Operating System gatecse-2019 numerical-answers operating-system fork-system-call 1-mark + – Arjun asked Feb 7, 2019 retagged Nov 30, 2022 by Lakshman Bhaiya Arjun 17.1k views answer comment Share Follow See all 6 Comments See all 6 6 Comments reply Show 3 previous comments mohan123 commented Nov 2, 2019 i edited by mohan123 Dec 24, 2020 reply Follow Share 5(0,2,4,6,8) times fork is called. Total number of child process would be 2^5−1=31 2 votes 2 votes Balwinder Pal Singh commented Jan 18, 2022 reply Follow Share HOW 0 is divided by 2 or a even no is still a mystery right 0 votes 0 votes santhosh_122 commented Aug 21, 2022 reply Follow Share fork will execute 5 times (i=0,2,4,6,8). so child processes created are 2^5-1=31 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes From 0 to 9, 0,2,4,6,8 are the values which will satisfy if condition. so fork will be called 5 times. total number of child processes will be 2^5-1=31 manikantsharma answered Jul 19, 2019 manikantsharma comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes 2^5 - 1 = 32 - 1 = 31 child processes. vikas001 answered Aug 18, 2019 vikas001 comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes fork is called at 0 , 2 ,4 ,6 ,8 i.e total 5 time So total number of child is 2^5-1 = 31. Shailendra_ answered Aug 24, 2019 Shailendra_ comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes i is initialized as 0 and it should be incremented by 2 and should go up to less than 10. consider this code: for(i=0; i<10; i=i+2) fork(); fork ( is a function) shall be called 5 times(i=0,2,4,6,8) equal to the no. of even numbers less than 10 ∴ Total number of process 2*2*2*2*2 =32 Total number of child process shall be 32−1=31 Brian Mwangangi answered Jan 23, 2020 reshown Jan 24, 2020 by Brian Mwangangi Brian Mwangangi comment Share Follow See all 0 reply Please log in or register to add a comment.