search
Log In
0 votes
127 views
Including the initial parent process, how many processes are created by the program shown below-

#include <stdio.h>
#include <unistd.h>
int main()
{
int i;
for (i = 0; i < 4; i++)
fork();
return 0;
}
in Operating System 127 views

1 Answer

0 votes

Total number of child process are created = $2^n$-1.

Here for loop executed 4 times( n=4) .

Total number of child process are created = $2^4$ -1 =16-1 = 15.

 


edited by

Related questions

1 vote
0 answers
1
122 views
Using the program in Figure 3.34, identify the values of pid at lines A, B, C, and D. (Assume that the actual pids of the parent and child are 2600 and 2603, respectively.) #include <sys/types.h> #include <stdio.h> #include <unistd.h> int main() { pid t pid, pid1; /* fork a child ... printf("parent: pid = %d",pid); /* C */ printf("parent: pid1 = %d",pid1); /* D */ wait(NULL); } return 0; }
asked Mar 19, 2019 in Operating System akash.dinkar12 122 views
0 votes
1 answer
2
345 views
Explain the circumstances under which which the line of code marked printf("LINE J") in following program will be reached. #include <sys/types.h> #include <stdio.h> #include <unistd.h> int main() { pid t pid; /* fork a child process */ pid = fork(); if (pid < 0) { / ... else { /* parent process */ /* parent will wait for the child to complete */ wait(NULL); printf("Child Complete"); } return 0; }
asked Mar 19, 2019 in Operating System akash.dinkar12 345 views
0 votes
0 answers
3
0 votes
0 answers
4
145 views
Construct a process tree similar to Figure 3.8. To obtain process information for the UNIX or Linux system, use the command ps -ael.Use the command man ps to get more information about the ps command.The task manager on Windows systems does not provide the parent process ID, but the process monitor tool, available from technet.microsoft.com, provides a process-tree tool.
asked Mar 19, 2019 in Operating System akash.dinkar12 145 views
...