Question: But some existing optimizing compilers (including gcc, which tends to be relatively conservative) will optimize count_positives to something similar to void count_positives(list l) { list

But some existing optimizing compilers (including gcc, which tends to be relatively conservative) will “optimize” count_positives to something similar to
void count_positives(list l)
{
list p;
register int r;
r = global_positives;
for (p = l; p; p = p -> next)
if (p -> val > 0.0) ++r;
global_positives = r;
}
What problem or potential problem occurs with this compiled version of the program if threads A and B are executed concurrently?

Step by Step Solution

3.31 Rating (166 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

This transformation is clearly consistent with the C language specification which ad... View full answer

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

Document Format (1 attachment)

Word file Icon

451-C-S-D-B-O-S (54).docx

120 KBs Word File

Students Have Also Explored These Related Operating System Questions!