Changeset b21c77a for src/tests/concurrent/examples/datingService.c
- Timestamp:
- Jun 29, 2018, 4:14:15 PM (7 years ago)
- Branches:
- new-env
- Children:
- 184557e
- Parents:
- 97397a26 (diff), 28f3a19 (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
r97397a26 rb21c77a 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.