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).
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment