in Compiler Design
329 views
0 votes
0 votes

Please explain how 2?

in Compiler Design
by
329 views

1 Answer

0 votes
0 votes
I think the line “The result of evaluating a+b will be the same if it is re-evaluated” explains a lot.

(I) is correct because when the entire program is running in a single thread, there is no chance that the value of ‘a+b’ will change from the line where we assign ‘temp = a+b’ to the end of the given code segment. So “top” and “bottom” are bound to have the same meaning.

(II) is correct because, when the given “bottom” is running in one thread, and the other parts of the program are running in other threads, then in this case the value of ‘a+b’ might change from the point that we assign ‘temp = a+b’ to the point of time where instructions like ‘temp < 0’ or ‘x = temp’ are executed. These changes in the values ‘a+b’ may occur due to changes made in different parts of the program running in different threads (a and b are accessible from anywhere as they are global variables). So there will a difference in what “top” and “bottom” do.

Since both the statements are correct, the answer is 2.