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 | |
| Line | |
|---|---|
| 1 | $input int B; |
| 2 | $input int N; |
| 3 | $assume 0<N && N<B; |
| 4 | int n = 3; |
| 5 | |
| 6 | void main(){ |
| 7 | int x; |
| 8 | |
| 9 | $atomic{ |
| 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 | } |
| 25 | } |
| 26 | $assert (x == 2 || x == 1); |
| 27 | } |
| 28 | } |
Note:
See TracBrowser
for help on using the repository browser.
