1 votes 1 votes Operating System fork-system-call + – amit166 asked Oct 12, 2018 amit166 616 views answer comment Share Follow See all 2 Comments See all 2 2 Comments reply MiNiPanda commented Oct 12, 2018 reply Follow Share Fork() returns 0 to the child process and some +ve value to the parent process. So Gate will be printed by the child and 2016 will be printed by the parent. Now order of execution cannot be determined..any of them can execute at first. So a and b are possible. 2 votes 2 votes shaktisingh commented Jun 30, 2019 reply Follow Share Note: If we don't write exit(0) in the if statement then both the child and parent will print the "2016". so this exit(0) statement makes the child to not print the "2016" 0 votes 0 votes Please log in or register to add a comment.
1 votes 1 votes both A and B are correct because the order of child and parent is not known. Sanandan answered Aug 28, 2020 Sanandan comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes Answer Will be 2, the order in which CPU execute either parent or child is nondeterministic. Avinash31 answered Nov 26, 2020 Avinash31 comment Share Follow See all 0 reply Please log in or register to add a comment.