Question: Please explain why explicitly For the following questions, consider the following C code (with some code omitted and replaced with ...) that uses the POSIX

Please explain why explicitly For the following questions, consider the following Ccode (with some code omitted and replaced with ...) that uses thePOSIX API: int global = 42; void *functioni (void *arg) { intPlease explain why explicitly

For the following questions, consider the following C code (with some code omitted and replaced with ...) that uses the POSIX API: int global = 42; void *functioni (void *arg) { int *p = (int*) arg; foo(p); return &global; } void *function2 (void *arg) { int *p = (int*) arg; foo(p); return &global; } void example() { pthread_t ti, t2; int x; pthread_create(&ti, NULL, functioni, &x); pthread_create(&t2, NULL, function2, &x); int *resulti; int *result2; pthread_join(ti, &resulti); pthread_join(t2, &result2); bar(resulti, result2); } You may assume that no failures occur (for example, pthread_create and pthread_join are always successful) and that the omitted code represented by ... does not return from functions, exit threads, or change the values of any variables shown above. On a single core system, when example() executes, function1 will call foo () function2 calls foo(). A. O before B. O after C. O sometimes before and sometimes after When example calls bar, resulti and result2 will A. always contain the same address, but dereferencing either pointer from bar() could crash because they now point to unallocated memory B. O always contain the same address, and dereferencing either pointer from bar () will not crash C. O usually not contain the same address, and dereferencing either pointer from bar() will not crash only contain the same address if functioni finishes before function2 starts, and dereferencing either pointer from bar( ) could crash because they now point D. to unallocated memory E. O never contain the same address

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!