Course Solutions Uncategorized (Solved) : 7 419 Program Shown Figure E423 Uses Pthreads Api Would Output Program Line C Line P Inclu Q35339066 . . . .

(Solved) : 7 419 Program Shown Figure E423 Uses Pthreads Api Would Output Program Line C Line P Inclu Q35339066 . . . .

 

7. 4.19 The program shown in Figure E4.23 usesthe Pthreads API. What would be the output from the program at LINEC and LINE P?

  #include

  #include

  

  int value = 0;

  void *runner(void *param); /* the thread */

  

  int main(int argc, char *argv[])

  {

  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 gt; 0) { /* parent process */

     wait(NULL);

     printf(“PARENT: value = %d”,value); /* LINE P */

   }

  }

  void *runner(void *param) {

     value = 5;

     pthread_exit(0);

  }

Figure E4.23 C program for Exercise 4.19.

Expert Answer


An answer will be send to you shortly. . .

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post