Question: The program shown in the following figure uses the Pthreads API. What would be the output from the program at LINE C and LINE P?

The program shown in the following figure uses the Pthreads API. What would be the output from the program at LINE C and LINE P?

The program shown in the following figure uses the Pthreads API. What

194 Chapter 4 Threads #include #include #include int value = 0; void *runner (void *param); /* the thread */ int main(int argc, char *argv[]) Prog pid.t pid; pthread_t tid; pthread_attr_t attr; pid = fork(); if (pid == 0) { /* child process */ pthread attr_init(&attr); pthread.create(&tid,&attr,runner ,NULL); pthread_join(tid,NULL); printf("CHILD: value = %d", value); /* LINE C */ else if (pid > 0) { /* parent process */ wait (NULL); printf ("PARENT: value = %d", value); /* LINE P */ void *runner (void *param) { value = 5; pthreadexit(); Figure 4.16 C program for Exercise 4.17. 4.19 Pthreads provides an API for managing thread cancellation." thread atalat

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!