Home /
Expert Answers /
Computer Science /
the-program-shown-in-figure-below-uses-the-pthreads-api-what-would-be-the-output-from-the-program-pa627
(Solved): The program shown in Figure below uses the pthreads API. What would be the output from the program ...
The program shown in Figure below uses the pthreads API. What would be the output from the program at LINE C and LINE P? (Please note that this problem is a little different from the one I did in class.) #include \( \langle \) pthread.b \( \rangle \) #include \( \langle \) stdio.b \( \rangle \) int value \( =0 \); void * runner (void * param); \( / \star \) the thread* \( / \) int main(int argc, char *argv) ? pid_t pid; pthread t tid; pthread_attr t attr; pid \( = \) fork ()\( \overline{\text {; }} \) value \( =1 \); if \( (\mathrm{pid}==0) \quad\{ \) pthread_attr_init (\&attr); pthread_create (\&tid, \&attr, runner, NULL) ; printf("CHILD: value", \%d", value); /* LINE C */ pthread_join (tid, NULL) ; \} else if (pid \( >0 \) ) \{ wait (NULL); printf("PAREHT: value \( ={ }^{*} d \) ", value); \( / \star \) LINE \( \mathrm{P} \star / \) \} \} void *runner(void * param) \( \uparrow \) value \( =5 \); pthread_exit \( (0) \); \}