1,254 views
4 votes
4 votes
Consider the below concurrent program

Int x= 0, y= 0;

Parbegin

begin

X=1;. //A

Y= Y +X.    //B

End

Begin

Y= 4;.     // C

X= X +5.      //D

End

Parend

What is the final value of x and y after computing the concurrent program.

1.  X=1     Y=5

2.X=  6     Y=10

3.X= 6       Y=5

4.X=1       Y=4

Which of the following is true

123

234

134

1234

1 Answer

Best answer
1 votes
1 votes

X = 0;
y = 0;

Execution Sequences:
1. A -> B -> C ->D, Thus, o/p X=6, Y=4

2. A -> C -> B -> D, Thus, o/p X=6, Y=5
3. C -> D -> A -> B, Thus, o/p X=1, Y=5
4. A -> C -> D -> B, Thus o/p X=6, Y=10

As we can see that outputs 1,2 and 3 are possible but not 4th.

123 is correct option.

selected by

Related questions

0 votes
0 votes
1 answer
1