All mock tests are FREE till 31 December — register to save your progress

Assuming fork() never fails, consider: P1: int main() { fork(); fork(); fork(); printf("Happy\n"); } and P2: int main() { fork(); printf("Happy\n"); fork(); fork(); printf("Happy\n"); }. Statement I: P1 displays "Happy" 8 times. Statement II: P2 displays "Happy" 12 times.

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: C. Statement I is correct but Statement II is false

Explanation

P1: three forks make 2³ = 8 processes, each printing once (8). P2: after one fork, 2 processes print (2); after two more forks, 8 processes print (8): 10 in total, not 12.

More System Software and Operating System questions