Answer to Question #39415 in C++ for uday tejan reddy

Question #39415
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).
0
Expert's answer

Answer in progress...

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS