Last change
on this file since 0522ebe was
9ee3f54,
checked in by Peter A. Buhr <pabuhr@…>, 3 years ago
|
disable time slicing on IO acquire tests to see if that prevents timeouts
|
-
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 : Fri Jan 14 09:14:06 2022 |
---|
13 | // Update Count : 73 |
---|
14 | // |
---|
15 | |
---|
16 | #include <fstream.hfa> |
---|
17 | #include <thread.hfa> |
---|
18 | #include <mutex_stmt.hfa> |
---|
19 | |
---|
20 | Duration default_preemption() { return 0; } |
---|
21 | |
---|
22 | thread T {}; |
---|
23 | void main( T & ) { |
---|
24 | // output from parallel threads should not be scrambled |
---|
25 | |
---|
26 | for ( 100 ) { // expression protection |
---|
27 | mutex(sout) sout | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; |
---|
28 | } |
---|
29 | mutex( sout ) { // statement protection |
---|
30 | for ( 100 ) { |
---|
31 | sout | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; |
---|
32 | } |
---|
33 | } |
---|
34 | { // duplicate protection demonstrating recursive lock |
---|
35 | ofstream & h1( ofstream & os ) { // helper |
---|
36 | mutex( os ) return os | 1 | 2 | 3 | 4; // unnecessary mutex |
---|
37 | } |
---|
38 | ofstream & h2( ofstream & os ) { // helper |
---|
39 | mutex( os ) return os | 6 | 7 | 8 | 9; // unnecessary mutex |
---|
40 | } |
---|
41 | mutex( sout ) { // unnecessary mutex |
---|
42 | for ( 100 ) { |
---|
43 | mutex( sout ) { |
---|
44 | sout | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; |
---|
45 | sout | h1 | 5 | h2; // refactored code |
---|
46 | } |
---|
47 | } |
---|
48 | } |
---|
49 | } |
---|
50 | } |
---|
51 | |
---|
52 | int main() { |
---|
53 | processor p; |
---|
54 | { |
---|
55 | T t[5]; |
---|
56 | } |
---|
57 | } |
---|
58 | |
---|
59 | // Local Variables: // |
---|
60 | // tab-width: 4 // |
---|
61 | // compile-command: "cfa io-acquire.cfa" // |
---|
62 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.