source:
CIVL/examples/languageFeatures/atomicStatement.cvl
| Last change on this file was ea777aa, checked in by , 3 years ago | |
|---|---|
|
|
| File size: 508 bytes | |
| Rev | Line | |
|---|---|---|
| [36b5ada] | 1 | /* Commandline execution: |
| 2 | * civl verify -inputB=3 atomicStatement.cvl | |
| 3 | * */ | |
| [e6b02c8] | 4 | #include<civlc.cvh> |
| [0baeebd] | 5 | $input int B = 3; |
| [2c448829] | 6 | $input int N; |
| [3ff27cf] | 7 | $assume(0<N && N<B); |
| [d410676] | 8 | int n = 3; |
| [9705dfd] | 9 | |
| 10 | void main(){ | |
| [e6b02c8] | 11 | int x; |
| 12 | ||
| 13 | $atomic{ | |
| 14 | $when(n > 1) n = 3; | |
| 15 | $atomic{ | |
| 16 | x = N; | |
| 17 | x = x * 2; | |
| 18 | } | |
| [d980649] | 19 | $assert(x == 2*N); |
| [e6b02c8] | 20 | // non-determinism allowed in $atomic block |
| 21 | $atomic{ | |
| 22 | x = 3; | |
| 23 | $choose { | |
| 24 | $when (n>2) { x=2; } | |
| 25 | $when (n>1) { x=1; } | |
| 26 | default: {x=0; } | |
| 27 | } | |
| 28 | } | |
| [d980649] | 29 | $assert(x == 2 || x == 1); |
| [e6b02c8] | 30 | } |
| [9705dfd] | 31 | } |
Note:
See TracBrowser
for help on using the repository browser.
