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).
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments