1.23
2.0
main
test-branch
|
Last change
on this file since 90dd7d7 was 2c448829, checked in by Manchun Zheng <zmanchun@…>, 12 years ago |
|
Improve the implementation for $atomic and $atom statements, taking into account non-determinism, blocking, loop, etc in $atomic blocks.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@379 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
268 bytes
|
| Line | |
|---|
| 1 | #include <civlc.h>
|
|---|
| 2 | $input int N;
|
|---|
| 3 | int sum = 0;
|
|---|
| 4 |
|
|---|
| 5 | void foo(int i){
|
|---|
| 6 | sum += i;
|
|---|
| 7 | }
|
|---|
| 8 |
|
|---|
| 9 | void main(){
|
|---|
| 10 | $atomic{
|
|---|
| 11 | $proc ps[N];
|
|---|
| 12 | for(int j = 1; j < N+1; j ++){
|
|---|
| 13 | ps[j-1] = $spawn foo(j);
|
|---|
| 14 | }
|
|---|
| 15 | for(int j = 1; j < N+1; j ++){
|
|---|
| 16 | $wait ps[j-1];
|
|---|
| 17 | }
|
|---|
| 18 | }
|
|---|
| 19 | $assert sum == N*(N+1)/2;
|
|---|
| 20 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.