// // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo // // The contents of this file are covered under the licence agreement in the // file "LICENCE" distributed with Cforall. // // io-acquire.cfa -- // // Author : Peter A. Buhr // Created On : Mon Mar 1 18:40:09 2021 // Last Modified By : Peter A. Buhr // Last Modified On : Fri Jan 14 09:13:43 2022 // Update Count : 73 // #include #include #include Duration default_preemption() { return 0; } // above output used as input to parallel threads thread T2 {}; void main( T2 & ) { int a, b, c, d, e, f, g, h, i; for ( 100 ) { // expression protection mutex(sin) sin | a | b | c | d | e | f | g | h | i; } mutex( sin ) { // statement protection for ( 100 ) { sin | a | b | c | d | e | f | g | h | i; } } { // duplicate protection demonstrating recursive lock ifstream & h1( ifstream & is ) { // helper mutex( is ) return is | a | b | c | d; // unnecessary mutex } ifstream & h2( ifstream & is ) { // helper mutex( is ) return is | f | g | h | i; // unnecessary mutex } mutex( sin ) { // unnecessary mutex for ( 5 ) { mutex( sin ) { sin | a | b | c | d | e | f | g | h | i; sin | h1 | e | h2; // refactored code } } } } } int main() { processor p; { T2 t[5]; } sout | "done"; } // Local Variables: // // tab-width: 4 // // compile-command: "cfa io-acquire.cfa" // // End: //