The following C program is executed on a Unix/Linux system: #include int main() { int i; for (i=0; i The total number of child processes created is …
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2019 · Q17
Time
#include <unistd.h>
int main()
{
int i;
for (i=0; i<10; i++)
if (i%2 == 0) fork();
return 0;
}The total number of child processes created is _______.Your answerNumerical answer
Solution
Official answer: 31
Processes, Threads and IPCThe for loop iterates for .
The condition i % 2 == 0 evaluates to true when , which is a total of times.
Each time fork() is called, all existing processes create a new child process, effectively doubling the total number of processes.
Total processes after fork() calls .
Since process is the original parent process, the total number of child processes created is:
Try the question first, then check your work.
Examiner trap
Count how many times fork() is executed in total across the loop iterations, and use the formula for the number of child processes created by sequential fork calls.
This Processes, Threads and IPC previous year question is Q17 of the GATE CSE 2019 paper. Find more GATE CSE PYQs on Processes, Threads and IPC in Operating Systems, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Processes, Threads and IPC PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
Processes, Threads and IPC has 15 GATE CSE PYQs across 13 papers from 2011 to 2026. 3 of them are 1-mark NAT questions like this one, and GATE CSE 2019 has 2.
How GATE tests Processes, Threads and IPCIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.