edited by
2,123 views
22 votes
22 votes

Consider the concurrent program 

x := 1; 
cobegin 
    x := x + x + 1 || x := x + 2 
coend;

Reading and writing of a variable is atomic, but evaluation of an expression is not atomic. The set of possible values of variable $x$ at the end of execution of the program is

  1. $\left\{3\right\}$
  2. $\left\{7\right\}$
  3. $\left\{3, 5, 7\right\}$
  4. $\left\{3, 7\right\}$
  5. $\left\{3, 5\right\}$
edited by

1 Answer

Best answer
18 votes
18 votes
$1. x = 1$, Run $x = x + 2$ then $x= x + x + 1$ finally $x$ will be $7$.
$2. x = 1$,  run $x = x + 2$ and $x = x + x + 1$, parallely ..
$x = 5 , 3$
Final answer would be $\{3, 5, 7\}$
edited by
Answer:

Related questions

13 votes
13 votes
2 answers
2
makhdoom ghaya asked Oct 26, 2015
1,695 views
The probability of throwing six perfect dices and getting six different faces is$1 -\dfrac{ 6!} { 6^{6}}$$\dfrac{6! }{ 6^{6}}$$6^{-6}$$1 - 6^{-6}$None of the above