in Operating System
404 views
1 vote
1 vote

 

in Operating System
by
404 views

2 Comments

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
2

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
0

2 Answers

1 vote
1 vote
both A and B are correct because the order of child and parent is not known.
0 votes
0 votes
Answer Will be 2, the order in which CPU execute either parent or child is nondeterministic.

Related questions