source: CIVL/examples/languageFeatures/civlBarrier.cvl@ a94cd4f

1.23 2.0 main test-branch
Last change on this file since a94cd4f was 48bfab9, checked in by Manchun Zheng <zmanchun@…>, 12 years ago

added checking for memory leak when collecting a dyscope and for process leak when the main process returns; fixed all test cases accordingly; added a filesystem_destroy call for IOTransformer to get rid of memory leak.

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

  • Property mode set to 100644
File size: 719 bytes
Line 
1/**
2 * This example demonstrates the features of CIVL's system function for implementing barriers.
3 */
4
5#include<civlc.h>
6
7$input int N;
8$gbarrier gbarrier = $gbarrier_create($here, N);
9int counter = 0;
10
11void process(int id) {
12 $barrier barrier = $barrier_create($here, gbarrier, id);
13
14 while($true){
15 $assert(counter == 0);
16 $barrier_call(barrier);
17 counter++;
18 $barrier_call(barrier);
19 $assert(counter == N);
20 $barrier_call(barrier);
21 counter--;
22 $barrier_call(barrier);
23 }
24 $barrier_destroy(barrier);
25}
26
27void main(){
28 $proc procs[N];
29
30 for(int i = 0; i < N; i++)
31 procs[i] = $spawn process(i);
32 for(int i = 0; i < N; i++)
33 $wait(procs[i]);
34 $gbarrier_destroy(gbarrier);
35}
Note: See TracBrowser for help on using the repository browser.