Changeset 28e58fd for src/tests/sched-int-disjoint.c
- Timestamp:
- Aug 25, 2017, 10:38:34 AM (8 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, resolv-new, with_gc
- Children:
- 800d275
- Parents:
- af08051 (diff), 3eab308c (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/sched-int-disjoint.c
raf08051 r28e58fd 20 20 21 21 monitor global_data_t; 22 void ?{}( global_data_t *this );23 void ^?{} ( global_data_t *this );22 void ?{}( global_data_t & this ); 23 void ^?{} ( global_data_t & this ); 24 24 25 25 monitor global_data_t { … … 32 32 volatile bool all_done; 33 33 34 void ?{}( global_data_t *this ) {35 this ->counter == 0;36 this ->state = BARGE;34 void ?{}( global_data_t & this ) { 35 this.counter == 0; 36 this.state = BARGE; 37 37 } 38 38 39 void ^?{} ( global_data_t *this ) {}39 void ^?{} ( global_data_t & this ) {} 40 40 41 41 //------------------------------------------------------------------------------ 42 42 // Barging logic 43 void barge( global_data_t *mutex d ) {44 d ->state = BARGE;43 void barge( global_data_t & mutex d ) { 44 d.state = BARGE; 45 45 } 46 46 47 47 thread Barger {}; 48 48 49 void main( Barger *this ) {49 void main( Barger & this ) { 50 50 while( !all_done ) { 51 barge( &data );51 barge( data ); 52 52 yield(); 53 53 } … … 56 56 //------------------------------------------------------------------------------ 57 57 // Waiting logic 58 bool wait( global_t * mutex m, global_data_t *mutex d ) {58 bool wait( global_t & mutex m, global_data_t & mutex d ) { 59 59 wait( &cond ); 60 if( d ->state != SIGNAL ) {60 if( d.state != SIGNAL ) { 61 61 sout | "ERROR barging!" | endl; 62 62 } 63 63 64 d ->counter++;64 d.counter++; 65 65 66 if( (d ->counter % 1000) == 0 ) sout | d->counter | endl;66 if( (d.counter % 1000) == 0 ) sout | d.counter | endl; 67 67 68 return d ->counter < N;68 return d.counter < N; 69 69 } 70 70 71 71 thread Waiter {}; 72 72 73 void main( Waiter *this ) {74 while( wait( &mut, &data ) ) { yield(); }73 void main( Waiter & this ) { 74 while( wait( mut, data ) ) { yield(); } 75 75 } 76 76 … … 78 78 //------------------------------------------------------------------------------ 79 79 // Signalling logic 80 void signal( condition * cond, global_t * mutex a, global_data_t *mutex b ) {81 b ->state = SIGNAL;80 void signal( condition * cond, global_t & mutex a, global_data_t & mutex b ) { 81 b.state = SIGNAL; 82 82 signal( cond ); 83 83 } 84 84 85 void logic( global_t *mutex a ) {86 signal( &cond, a, &data );85 void logic( global_t & mutex a ) { 86 signal( &cond, a, data ); 87 87 88 88 yield( (unsigned)rand48() % 10 ); … … 97 97 thread Signaller {}; 98 98 99 void main( Signaller *this ) {99 void main( Signaller & this ) { 100 100 while( !all_done ) { 101 logic( &mut );101 logic( mut ); 102 102 yield(); 103 103 }
Note:
See TracChangeset
for help on using the changeset viewer.