source:
CIVL/examples/languageFeatures/atomicStatement.cvl@
90dd7d7
| Last change on this file since 90dd7d7 was 90dd7d7, checked in by , 12 years ago | |
|---|---|
|
|
| File size: 374 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{ |
| [90dd7d7] | 10 | $when(n > 1) n = 3; |
| 11 | ||
| 12 | $atomic{ | |
| 13 | x = N; | |
| 14 | x = x * 2; | |
| 15 | } | |
| 16 | $assert x == 2*N; | |
| 17 | // non-determinism allowed in $atomic block | |
| 18 | $atomic{ | |
| 19 | x = 3; | |
| 20 | $choose { | |
| 21 | $when (n>2) { x=2; } | |
| 22 | $when (n>1) { x=1; } | |
| 23 | default: {x=0; } | |
| 24 | } | |
| [9705dfd] | 25 | } |
| [90dd7d7] | 26 | $assert (x == 2 || x == 1); |
| [9705dfd] | 27 | } |
| 28 | } |
Note:
See TracBrowser
for help on using the repository browser.
