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? (Ple
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) \); \}


We have an Answer from Expert

View Expert Answer

Expert Answer


/* If fork is called, it will create child process from parent process which dont share memory between parent and child i.e if you change any variable
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe