ADT
ast-experimental
enum
forall-pointer-decay
pthread-emulation
qualifiedEnum
Last change
on this file since f57f6ea0 was 3bb12921, checked in by caparsons <caparson@…>, 4 years ago |
added new io tests
|
-
Property mode
set to
100644
|
File size:
1.5 KB
|
Line | |
---|
1 | //
|
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
|
---|
3 | //
|
---|
4 | // The contents of this file are covered under the licence agreement in the
|
---|
5 | // file "LICENCE" distributed with Cforall.
|
---|
6 | //
|
---|
7 | // io-acquire.cfa --
|
---|
8 | //
|
---|
9 | // Author : Peter A. Buhr
|
---|
10 | // Created On : Mon Mar 1 18:40:09 2021
|
---|
11 | // Last Modified By : Peter A. Buhr
|
---|
12 | // Last Modified On : Wed Oct 6 18:04:58 2021
|
---|
13 | // Update Count : 72
|
---|
14 | //
|
---|
15 |
|
---|
16 | #include <fstream.hfa>
|
---|
17 | #include <thread.hfa>
|
---|
18 | #include <mutex_stmt.hfa>
|
---|
19 |
|
---|
20 | // above output used as input to parallel threads
|
---|
21 | thread T2 {};
|
---|
22 | void main( T2 & ) {
|
---|
23 | int a, b, c, d, e, f, g, h, i;
|
---|
24 | for ( 100 ) { // expression protection
|
---|
25 | mutex(sin) sin | a | b | c | d | e | f | g | h | i;
|
---|
26 | }
|
---|
27 | mutex( sin ) { // statement protection
|
---|
28 | for ( 100 ) {
|
---|
29 | sin | a | b | c | d | e | f | g | h | i;
|
---|
30 | }
|
---|
31 | }
|
---|
32 | { // duplicate protection demonstrating recursive lock
|
---|
33 | ifstream & h1( ifstream & is ) { // helper
|
---|
34 | mutex( is ) return is | a | b | c | d; // unnecessary mutex
|
---|
35 | }
|
---|
36 | ifstream & h2( ifstream & is ) { // helper
|
---|
37 | mutex( is ) return is | f | g | h | i; // unnecessary mutex
|
---|
38 | }
|
---|
39 | mutex( sin ) { // unnecessary mutex
|
---|
40 | for ( 5 ) {
|
---|
41 | mutex( sin ) {
|
---|
42 | sin | a | b | c | d | e | f | g | h | i;
|
---|
43 | sin | h1 | e | h2; // refactored code
|
---|
44 | }
|
---|
45 | }
|
---|
46 | }
|
---|
47 | }
|
---|
48 | }
|
---|
49 | int main() {
|
---|
50 | processor p;
|
---|
51 | {
|
---|
52 | T2 t[5];
|
---|
53 | }
|
---|
54 | sout | "done";
|
---|
55 | }
|
---|
56 |
|
---|
57 | // Local Variables: //
|
---|
58 | // tab-width: 4 //
|
---|
59 | // compile-command: "cfa io-acquire.cfa" //
|
---|
60 | // End: //
|
---|
Note:
See
TracBrowser
for help on using the repository browser.