Question: Trace the output for the C program in Figure , and answer the following questions: What is the output of Line A ? What is

Trace the output for the C program in Figure , and answer the following questions:
What is the output of Line A ?
What is the output of Line B ?
What is the final value of glob_data before the program is terminated?
 Trace the output for the C program in Figure , and

1 #include 2 #include 3 #include 4 #include 5 #include 6 7 int glob_data = 0; 8 9 void *runnerfunc(void *p) { 10 glob_data - 5; 11 pthread_exit(); 12 13 14 int main() 15 BU 16 int pid; 17 pthread_t tid; 18 pthread_attr_t attr; 20 pid - fork(); 21 if (pid - ) 22 pthread_attr_init(&attr); 23 pthread_create(&tid, &attr,runnerfunc, NULL); 24 pthread_join(tid, NULL); 25 printf("CHILD: value = $d ",glob_data); /* LINE A */ 26 } else if (pid > 0) { 27 wait (NULL); 28 printf("PARENT: value = $d ",glob_data); /* LINE B / 29 } 30 return 0; 31 Figure 2 C-Code for Exercise A-2

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 Databases Questions!