Answered step by step
Verified Expert Solution
Question
1 Approved Answer
4. Threads Use the pseudo code below for this question. Note that it is using the Linux implementation of threading (i.e., PTHREADs) as a basis
4. Threads Use the pseudo code below for this question. Note that it is using the Linux implementation of threading (i.e., PTHREADs) as a basis for the question As in question 3, the code will not compile, but you may find it useful to code up a short example to check your answers. what is the value of the variable value" at: a. (5 pts) LINE D b. (5 pts) LINE E c. (5 pts) LINE F int value 0; void *runner(void *param); /*thread*/ int main(int argc, char *argvl) pid t pid; pthread r tid pthread_attr attr; pid fork() f (pido) /*child process*/ value -value10; pthread attr_init (&attr) pthread create (tid,&attr, runner, NULL); pthread _join(tid, NULL); printf("CHILD: value-96d, value); /*LINE D*/ Else if (pid>0) /*parent process/ wait (NULL); printf ("PARENT: value = %d, value); /*LINEE"/ Void runner (void *param) value value+ 5; printf("CHILD: value = %d, value); LINE F pthread_exit(0); 4. Threads Use the pseudo code below for this question. Note that it is using the Linux implementation of threading (i.e., PTHREADs) as a basis for the question As in question 3, the code will not compile, but you may find it useful to code up a short example to check your answers. what is the value of the variable value" at: a. (5 pts) LINE D b. (5 pts) LINE E c. (5 pts) LINE F int value 0; void *runner(void *param); /*thread*/ int main(int argc, char *argvl) pid t pid; pthread r tid pthread_attr attr; pid fork() f (pido) /*child process*/ value -value10; pthread attr_init (&attr) pthread create (tid,&attr, runner, NULL); pthread _join(tid, NULL); printf("CHILD: value-96d, value); /*LINE D*/ Else if (pid>0) /*parent process/ wait (NULL); printf ("PARENT: value = %d, value); /*LINEE"/ Void runner (void *param) value value+ 5; printf("CHILD: value = %d, value); LINE F pthread_exit(0)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started