Question: Answer the following questions with the program. a. How many child processes are created? Briefly explain your answer. b. Is it possible for two child
Answer the following questions with the program.
a. How many child processes are created? Briefly explain your answer. b. Is it possible for two child processes to be executing concurrently? Briefly explain your answer. c. Would the program behave the same way if the if-else statements were replaced with the following? Briefly explain your answer. if (pid == 0) { /* child process */ printf("Child "); return 0; } wait(NULL); printf("Parent ");
The information for program.
#include
int main() { pid_t pid;
/* fork a child process */ pid = fork();
if (pid == 0) { /* child process */ printf("Child "); return 0; } else { /* parent process */ wait(NULL); printf("Parent "); }
/* fork a child process */ pid = fork();
if (pid == 0) { /* child process */ printf("Child "); return 0; } else { /* parent process */ wait(NULL); printf("Parent "); } return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
