source: CIVL/mods/dev.civl.abc/examples/link/barrier/barrier.cvl

main
Last change on this file was aad342c, checked in by Stephen Siegel <siegel@…>, 3 years ago

Performing huge refactor to incorporate ABC, GMC, and SARL into CIVL repo and use Java modules.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5664 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 813 bytes
Line 
1/**
2 * Test me: abc -iquote examples/link/barrier examples/link/barrier/barrier.cvl examples/link/barrier/concurrency.cvl
3 */
4
5#include<civlc.cvh>
6#include<concurrency.cvh>
7
8$input int N;
9$input int B;
10$assume(N > 0 && N < B);
11$gbarrier gbarrier = $gbarrier_create($here, N);
12int counter = 0;
13
14void process(int id) {
15 $barrier barrier = $barrier_create($here, gbarrier, id);
16
17 while($true){
18 $assert((counter == 0));
19 $barrier_call(barrier);
20 counter++;
21 $barrier_call(barrier);
22 $assert((counter == N));
23 $barrier_call(barrier);
24 counter--;
25 $barrier_call(barrier);
26 }
27 $barrier_destroy(barrier);
28}
29
30void main(){
31 $proc procs[N];
32
33 for(int i = 0; i < N; i++)
34 procs[i] = $spawn process(i);
35 for(int i = 0; i < N; i++)
36 $wait(procs[i]);
37 $gbarrier_destroy(gbarrier);
38}
Note: See TracBrowser for help on using the repository browser.