Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 1 (1 points): Consider the following C code that uses the POSIX threading API: pthread_t a, b; struct point { int x, y; };
Question 1 (1 points): Consider the following C code that uses the POSIX threading API: pthread_t a, b; struct point { int x, y; }; void *bar(void *arg) { struct point *p = (struct point *) arg; printf("%d ", p->x); void *foo (void *arg) { struct point *initial = (struct point *) arg; struct point new; new.x = initial->x; new.y = initial->y; pthread_create(&b, NULL, bar, (void*) &new); pthread_join(b, NULL); int main(void) { struct point *main_pt = malloc(sizeof(struct point)); main_pt->x = 100; main pt->y = 120; pthread_create(&a, NULL, foo, main_pt); pthread_join(a, NULL); free (main_pt); Ignore any minor syntax errors above, assume all appropriate headers are included and that the pthread functions do not fail. _? When this code is run p->x in bar most likely will access_ A. O a value stored on thread b's stack B. O a value stored in a register in thread b a value stored in a global variable D. O a value stored on thread a's stack E. O a value stored in a register in thread a F. O a value stored in the heap
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