Question: Question 1 . [ 4 marks ] Consider the execution of the following function ( written in the C language ) . / / all

Question 1.[4 marks]
Consider the execution of the following function (written in the C language).
// all the needed headers are included
intmain()
{
intpid;
if((pid = fork())==0){
printf("A");
exit(0);
}
printf("B");
if(fork()==0){
printf("C");
exit(0);
}
printf("D");
waitpid(pid,NULL,0);
printf("E");
exit(0);
}
1(a) Draw the process graph for the concurrent program.
In a process graph, each function, including main(), fork(), printf(), waitpid(), and exit(), is represented by a vertex. For each vertex, please write the function name below the vertex, and for printf() write the output character above the vertex. Assume calling printf() will immediately display the content on the screen. Each edge must be directed, with the direction representing the happen-before relationship.

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!