Changeset 200fcb3 for tests/concurrent/examples
- Timestamp:
- Dec 12, 2018, 9:16:12 AM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 5ebb1368
- Parents:
- 3d99498
- Location:
- tests/concurrent/examples
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrent/examples/boundedBufferEXT.c
r3d99498 r200fcb3 8 8 // Created On : Wed Apr 18 22:52:12 2018 9 9 // Last Modified By : Peter A. Buhr 10 // Last Modified On : T hu Aug 16 08:17:03201811 // Update Count : 810 // Last Modified On : Tue Dec 11 21:55:02 2018 11 // Update Count : 9 12 12 // 13 13 … … 115 115 sum += sums[i]; 116 116 } // for 117 sout | "total:" | sum | endl;117 sout | "total:" | sum; 118 118 } 119 119 -
tests/concurrent/examples/boundedBufferINT.c
r3d99498 r200fcb3 8 8 // Created On : Mon Oct 30 12:45:13 2017 9 9 // Last Modified By : Peter A. Buhr 10 // Last Modified On : T hu Aug 16 08:17:58201811 // Update Count : 8 310 // Last Modified On : Tue Dec 11 21:55:45 2018 11 // Update Count : 84 12 12 // 13 13 … … 116 116 sum += sums[i]; 117 117 } // for 118 sout | "total:" | sum | endl;118 sout | "total:" | sum; 119 119 } 120 120 -
tests/concurrent/examples/datingService.c
r3d99498 r200fcb3 8 8 // Created On : Mon Oct 30 12:56:20 2017 9 9 // Last Modified By : Peter A. Buhr 10 // Last Modified On : Sun May 27 09:05:18201811 // Update Count : 2 610 // Last Modified On : Tue Dec 11 21:55:34 2018 11 // Update Count : 28 12 12 // 13 13 … … 58 58 yield( random( 100 ) ); // don't all start at the same time 59 59 unsigned int partner = girl( TheExchange, id, ccode ); 60 sout | "Girl:" | id | "is dating Boy at" | partner | "with ccode" | ccode | endl;60 sout | "Girl:" | id | "is dating Boy at" | partner | "with ccode" | ccode; 61 61 girlck[id] = partner; 62 62 } // Girl main … … 69 69 70 70 thread Boy { 71 DatingService & TheExchange;71 DatingService & TheExchange; 72 72 unsigned int id, ccode; 73 73 }; // Boy … … 76 76 yield( random( 100 ) ); // don't all start at the same time 77 77 unsigned int partner = boy( TheExchange, id, ccode ); 78 sout | " Boy:" | id | "is dating Girl" | partner | "with ccode" | ccode | endl;78 sout | " Boy:" | id | "is dating Girl" | partner | "with ccode" | ccode; 79 79 boyck[id] = partner; 80 80 } // Boy main -
tests/concurrent/examples/matrixSum.c
r3d99498 r200fcb3 11 11 // Created On : Mon Oct 9 08:29:28 2017 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Tue Nov 6 17:51:32201814 // Update Count : 1 413 // Last Modified On : Tue Dec 11 21:54:55 2018 14 // Update Count : 15 15 15 // 16 16 … … 54 54 total += subtotals[r]; // total subtotals 55 55 } // for 56 sout | total | endl;56 sout | total; 57 57 } 58 58 -
tests/concurrent/examples/quickSort.c
r3d99498 r200fcb3 9 9 // Created On : Wed Dec 6 12:15:52 2017 10 10 // Last Modified By : Peter A. Buhr 11 // Last Modified On : T hu Aug 16 08:17:41201812 // Update Count : 16 311 // Last Modified On : Tue Dec 4 18:00:27 2018 12 // Update Count : 167 13 13 // 14 14 … … 88 88 89 89 void usage( char * argv[] ) { 90 sout | "Usage:" | argv[0] | "( -s unsorted-file [ sorted-file ] | -t size (>= 0) [ depth (>= 0) ] )" | endl;90 sout | "Usage:" | argv[0] | "( -s unsorted-file [ sorted-file ] | -t size (>= 0) [ depth (>= 0) ] )"; 91 91 exit( EXIT_FAILURE ); // TERMINATE! 92 92 } // usage … … 114 114 &sortedfile = new( (const char *)argv[2] ); // open the output file 115 115 if ( fail( sortedfile ) ) { 116 serr | "Error! Could not open sorted output file \"" | argv[2] | "\"" | endl;116 serr | "Error! Could not open sorted output file \"" | argv[2] | "\""; 117 117 usage( argv ); 118 118 } // if … … 121 121 &unsortedfile = new( (const char *)argv[1] ); // open the input file 122 122 if ( fail( unsortedfile ) ) { 123 serr | "Error! Could not open unsorted input file \"" | argv[1] | "\"" | endl;123 serr | "Error! Could not open unsorted input file \"" | argv[1] | "\""; 124 124 usage( argv ); 125 125 } // if … … 127 127 } // if 128 128 } // if 129 sortedfile | nlOff; // turn off auto newline 129 130 130 131 enum { ValuesPerLine = 22 }; // number of values printed per line … … 137 138 for ( int counter = 0; counter < size; counter += 1 ) { // read unsorted numbers 138 139 unsortedfile | values[counter]; 139 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | endl | " ";140 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | nl | " "; 140 141 sortedfile | values[counter]; 141 142 if ( counter < size - 1 && (counter + 1) % ValuesPerLine != 0 ) sortedfile | ' '; 142 143 } // for 143 sortedfile | endl;144 sortedfile | nl; 144 145 if ( size > 0 ) { // values to sort ? 145 146 Quicksort QS = { values, size - 1, 0 }; // sort values 146 147 } // wait until sort tasks terminate 147 148 for ( int counter = 0; counter < size; counter += 1 ) { // print sorted list 148 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | endl | " ";149 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | nl | " "; 149 150 sortedfile | values[counter]; 150 151 if ( counter < size - 1 && (counter + 1) % ValuesPerLine != 0 ) sortedfile | ' '; 151 152 } // for 152 sortedfile | endl | endl;153 sortedfile | nl; 153 154 154 155 delete( values );
Note: See TracChangeset
for help on using the changeset viewer.