Assume this is a pthreads program


Consider the following C pseudo-code. The variable global sum is a globally shared variable.
Assume this is a Pthreads program and the code is part of what executes in one of the threads.
for (i = 0; i < mymax; i++) {
global_sum += do_something(i,other-parameters);
}
(a) Explain the program execution flaw in this code. (Identify the problem and what it potentially results in.)
(b) Show how the flaw can be fixed inside the for loop - i.e. without adding any additional code after the loop.
(c) Show (through code or just explanation) how to address the performance problem with the fix in part (b).

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Assume this is a pthreads program
Reference No:- TGS084303

Expected delivery within 24 Hours