Question
1.
2.
3.
4.
Answer (Detailed Solution Below)
Option 2 : 6 / 6
Advertisement
Detailed Solution
सही उत्तर 6 / 6 है।
Key Points
Helpful?
Question:
How many total processes exist after this C program runs, including the initial process? Code: fork(); if (fork()) fork(); / इस C प्रोग्राम के चलने के बाद प्रारंभिक प्रोसेस सहित कुल कितनी प्रोसेस होंगी? कोड: fork(); if (fork()) fork();
1.
4 / 4
2.
6 / 6
3.
8 / 8
4.
5 / 5
Correct Answer: 6 / 6
The first fork() creates 2 processes. Each executes the fork() inside the if condition, making 4. fork() returns a nonzero child PID in the parent and 0 in the child, so only the 2 parents take the if-branch and fork again, adding 2 more. Total = 4 + 2 = 6. The trap answer 8 assumes every process forks three times. / पहला fork() 2 प्रोसेस बनाता है; if वाला fork() 4 बनाता है; केवल 2 पैरेंट फिर fork() करते हैं, कुल 6।
Downloaded from PrepSnap (prepsnap.in)