2 2 votes fork(); fork(); printf("Gate2024"); fork();what will be the answer? Operating System operating-system fork-system-call numerical-answers made-easy-test-series + – abhiagr2 1.2k views answer comment Share Follow Print See all 4 Comments 4 4 Comments reply abhiagr2 commented Oct 19, 2024 reply Follow flag i know on first look it looks like 4. I am getting 8. my logic is printf is buffered output so it waits till execution of last fork and then for the 8 processes(1parent and 7 child) it flushes the "Gate2024". Please correct me if my logic is incorrect. thanks 0 0 replyShare merohan17 commented Oct 19, 2024 reply Follow flag It prints, 4-times "Gate 2024" with 8 child processes created 2 2 replyShare Hira Thakur commented Nov 28, 2024 reply Follow flag only 4 times print the message and 8 times process is created (one parent+seven child) 2 2 replyShare Chandrabhan Vishwa 1 commented Nov 28, 2024 i edited by Chandrabhan Vishwa 1 Nov 29, 2024 reply Follow flag yes every one is correct in the comment here 4 times printed because when first time fork is called the one child and one parent created and second time called then child is created two process and parent also created two process so total 4 process is created so after this every four process call the printf statement and and print four time Gate2024 and last fork created total 8 process so only 4 time Gate 2024 is printed 0 0 replyShare Please log in or register to add a comment.
0 0 votes Here, first two fork()'s will be executed and "Gate2024" will be printed 4 times with one parent process and 3 child proceses , last fork() executes and 8 processes(1 parent , 7 child) will be created. Steve_Harry answered Nov 28, 2024 Steve_Harry comment Share Follow 0 reply Please log in or register to add a comment.