Changeset 054514d for src/tests/concurrent/examples/datingService.c
- Timestamp:
- May 29, 2018, 3:26:31 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
- Children:
- 3530f39a
- Parents:
- 96812c0 (diff), da60c631 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/concurrent/examples/datingService.c
r96812c0 r054514d 8 8 // Created On : Mon Oct 30 12:56:20 2017 9 9 // Last Modified By : Peter A. Buhr 10 // Last Modified On : Wed Mar 14 22:48:40201811 // Update Count : 2 310 // Last Modified On : Sun May 27 09:05:18 2018 11 // Update Count : 26 12 12 // 13 13 … … 18 18 #include <unistd.h> // getpid 19 19 20 enum { NoOfPairs = 20 };20 enum { CompCodes = 20 }; // number of compatibility codes 21 21 22 22 monitor DatingService { 23 condition Girls[ NoOfPairs], Boys[NoOfPairs];23 condition Girls[CompCodes], Boys[CompCodes]; 24 24 unsigned int GirlPhoneNo, BoyPhoneNo; 25 25 }; // DatingService … … 47 47 } // DatingService boy 48 48 49 unsigned int girlck[ NoOfPairs];50 unsigned int boyck[ NoOfPairs];49 unsigned int girlck[CompCodes]; 50 unsigned int boyck[CompCodes]; 51 51 52 52 thread Girl { … … 88 88 int main() { 89 89 DatingService TheExchange; 90 Girl * girls[ NoOfPairs];91 Boy * boys[ NoOfPairs];90 Girl * girls[CompCodes]; 91 Boy * boys[CompCodes]; 92 92 93 93 srandom( /*getpid()*/ 103 ); 94 94 95 for ( unsigned int i = 0; i < NoOfPairs; i += 1 ) {95 for ( unsigned int i = 0; i < CompCodes; i += 1 ) { 96 96 girls[i] = new( &TheExchange, i, i ); 97 boys[i] = new( &TheExchange, i, NoOfPairs - ( i + 1 ) );97 boys[i] = new( &TheExchange, i, CompCodes - ( i + 1 ) ); 98 98 } // for 99 99 100 for ( unsigned int i = 0; i < NoOfPairs; i += 1 ) {100 for ( unsigned int i = 0; i < CompCodes; i += 1 ) { 101 101 delete( boys[i] ); 102 102 delete( girls[i] ); 103 103 } // for 104 104 105 for ( unsigned int i = 0; i < NoOfPairs; i += 1 ) {105 for ( unsigned int i = 0; i < CompCodes; i += 1 ) { 106 106 if ( girlck[ boyck[i] ] != boyck[ girlck[i] ] ) abort(); 107 107 } // for
Note: See TracChangeset
for help on using the changeset viewer.