Question: Consider the following program: ` ` ` int a = 7 , f; cout getpid ( ) : a endl; f = fork

Consider the following program:
```
int a =7, f;
cout getpid()": " a endl;
f = fork();
if(f !=0)
a--;
cout getpid()": " a endl;
f = fork();
if(f ==0)
{
a +=4;
cout getpid()": " a endl;
}
else
{
a -=3;
cout getpid()": " a endl;
fork();
}
a +=2;
cout getpid()": " a endl;
```
Provide the process tree created by this program and determine the output of each process. When displaying the process ID of a process (getpid()), use the following notation: p1 for the initial process, p 11 for its first child, p 12 for its second child, p 111 for the first child of p 11, and so on.
Consider the following program: ` ` ` int a = 7 ,

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!