source:
CIVL/examples/languageFeatures/atomicStatement.cvl@
38b7d06
| Last change on this file since 38b7d06 was 2c448829, checked in by , 12 years ago | |
|---|---|
|
|
| File size: 322 bytes | |
| Rev | Line | |
|---|---|---|
| [2c448829] | 1 | $input int B; |
| 2 | $input int N; | |
| 3 | $assume 0<N && N<B; | |
| [d410676] | 4 | int n = 3; |
| [9705dfd] | 5 | |
| 6 | void main(){ | |
| [2c448829] | 7 | int x; |
| [9705dfd] | 8 | |
| [2c448829] | 9 | $atomic{ |
| 10 | x = N; | |
| 11 | x = x * 2; | |
| 12 | } | |
| 13 | $assert x == 2*N; | |
| [10e8759] | 14 | // non-determinism allowed in $atomic block |
| [9705dfd] | 15 | $atomic{ |
| [2c448829] | 16 | x = 3; |
| [10e8759] | 17 | $choose { |
| 18 | $when (n>2) { x=2; } | |
| 19 | $when (n>1) { x=1; } | |
| 20 | default: {x=0; } | |
| [9705dfd] | 21 | } |
| 22 | } | |
| [10e8759] | 23 | $assert (x == 2 || x == 1); |
| [9705dfd] | 24 | } |
Note:
See TracBrowser
for help on using the repository browser.
