Question: Consider the following program: P 1 : { shared int x; x = 1 0 ; while ( 1 ) { x = x -
Consider the following program:
P:
shared int x;
x ;
while
x x ;
x x ;
if x
printfx is d x
P:
shared int x;
x ;
while
x x ;
x x ;
if x
printfx is d x
For each of the following outputs, if it is possible to have that output, show an interleaving of statements that would result in the output.
x is is printed.
X is is printed.
You should remember that the incrementdecrements at the source language level are not done atomically, that is the assembly language code:
LD RO X load RO from memory location x
INCR RO increment RO
STO RO X store the incremented value back in X
implements the single C increment instruction.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
