source: CIVL/include/headers/concurrency_contract.cvh@ 1aaefd4

main test-branch
Last change on this file since 1aaefd4 was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

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

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/* This header file contains the function prototypes for
2 * concurrency.
3 */
4
5#ifndef _CONCURRENCY_
6#define _CONCURRENCY_
7
8/* includes civlc.cvh because this library references $scope */
9#include <civlc.cvh>
10#include <bundle.cvh>
11
12/* ********************************* Types ********************************* */
13
14/* A data type representing a global barrier which must be operated by local
15 * barriers.
16 */
17typedef struct $gbarrier * $gbarrier;
18
19/* A data type representing a global barrier which used for
20 * operating global barriers. The local barrier type has
21 * a handle of a global barrier.
22 */
23typedef struct $barrier * $barrier;
24
25/* ******************************* Functions ******************************* */
26
27/* Creates a new barrier object and returns a handle to it.
28 * The barrier has the specified size.
29 * The new object will be allocated in the given scope. */
30/*@ requires scope <= $root;
31 @ requires size >= 0;
32 @ $depends \nothing;
33 @ $guards $true;
34 @ assigns \nothing;
35 @ */
36$gbarrier $gbarrier_create($scope scope, int size);
37
38/* Destroys the gbarrier */
39/*@ requires barrier != \null;
40 @ $guards $true;
41 @ $depends \nothing;
42 @ assigns barrier;//barrier has pointer type, and is converted into $memory type automatically
43 @ */
44void $gbarrier_destroy($gbarrier barrier);
45
46/* checks if the global barrier has a vacancy at the specified place */
47/*@ requires place >= 0;
48 @*/
49bool $gbarrier_vacant($gbarrier barrier, int place);
50
51/* returns the process reference that takes the given place of the global barrier */
52$proc $gbarrier_process_at($gbarrier barrier, int place);
53
54/* Creates a new local barrier object and returns a handle to it.
55 * The new barrier will be affiliated with the specified global
56 * barrier. This local barrier handle will be used as an
57 * argument in most barrier functions. The place must be in
58 * [0,size-1] and specifies the place in the global barrier
59 * that will be occupied by the local barrier.
60 * Only one call to $barrier_create may occur for each barrier-place pair.
61 * The new object will be allocated in the given scope. */
62/*@ requires scope <= $root && gbarrier!=\null && place >= 0;
63 *@ ensures $gbarrier_process_at(gbarrier, place)==$self;
64 *@ $depends $calls($barrier_create, $everything, gbarrier, place);
65 *@ assigns \nothing;
66 *@ behavior success:
67 *@ assumes $gbarrier_vacant(gbarrier, place);
68 *@ allocates \result, scope;
69 *@ behavior failure:
70 *@ assumes !$gbarrier_vacant(gbarrier, place);
71 *@ allocates \nothing, scope;
72 *@ complete behaviors;
73 *@ disjoint behaviors;
74 */
75$barrier $barrier_create($scope scope, $gbarrier gbarrier, int place);
76
77/* Destroys the barrier. */
78/*@ requires barrier != \null ==> \freeable{Here}(barrier);
79 @ assigns \nothing;
80 @ frees barrier;
81 @ ensures barrier !=null ==> \allocable{Here}{barrier}; // what does it mean by \allocable?
82 @ // the above is actually copied from ACSL reference where there is an example of contracts for free().
83 @
84 @*/
85void $barrier_destroy($barrier barrier);
86
87/* Calls the barrier associated with this local barrier object.*/
88/*@ $depends \nothing;
89 @ assigns \nothing; // although the barrier records is updated but it gets cleaned up when the method returns
90 @*/
91void $barrier_call($barrier barrier);
92
93/********* Functions For Collective Arrive Checking Record *********/
94/* Collective checker record entry */
95typedef struct $collect_record $collect_record;
96
97/* Global collective operation checker */
98typedef struct $gcollect_checker * $gcollect_checker;
99
100/* Local handle of the collective operation checker */
101typedef struct $collect_checker * $collect_checker;
102
103/* Creates and initializes the global collective operation checker */
104$gcollect_checker $gcollect_checker_create($scope scope);
105
106/* Destroy a global collective operation checker */
107void $gcollect_checker_destroy($gcollect_checker checker);
108
109/* Creates and initializes the local collective operation checker */
110$collect_checker $collect_checker_create($scope scope,
111 $gcollect_checker gchecker);
112
113/* Destroy a local collective operation checker */
114void $collect_checker_destroy($collect_checker checker);
115
116/* Do a check for a collecive operation of one process */
117_Bool $collect_check($collect_checker checker, int place, int nprocs,
118 $bundle entries);
119
120#endif
Note: See TracBrowser for help on using the repository browser.