Changeset c7816be
- Timestamp:
- Jun 24, 2020, 2:47:04 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 8ae4165
- Parents:
- 52769ba
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrent/signal/disjoint.cfa
r52769ba rc7816be 21 21 #endif 22 22 23 // This tests checks what happens when someone barges in the midle of the release 24 // of a bulk of monitors. 25 23 26 enum state_t { WAIT, SIGNAL, BARGE }; 24 27 25 28 monitor global_t {}; 26 global_t mut;27 29 28 30 monitor global_data_t; … … 33 35 int counter; 34 36 state_t state; 35 } data; 37 }; 38 39 // Use a global struct because the order needs to match with Signaller thread 40 struct { 41 global_t mut; 42 global_data_t data; 43 } globals; 36 44 37 45 condition cond; … … 40 48 41 49 void ?{}( global_data_t & this ) { 42 this.counter = =0;50 this.counter = 0; 43 51 this.state = BARGE; 44 52 } … … 59 67 void main( Barger & this ) { 60 68 while( !all_done ) { 61 barge( data );69 barge( globals.data ); 62 70 yield(); 63 71 } … … 86 94 87 95 void main( Waiter & this ) { 88 while( wait( mut,data ) ) { KICK_WATCHDOG; yield(); }96 while( wait( globals.mut, globals.data ) ) { KICK_WATCHDOG; yield(); } 89 97 } 90 98 … … 98 106 99 107 void logic( global_t & mutex a ) { 100 signal( cond, a, data );108 signal( cond, a, globals.data ); 101 109 102 110 yield( random( 10 ) ); 103 111 104 112 //This is technically a mutual exclusion violation but the mutex monitor protects us 105 bool running = TEST( data.counter < N) &&data.counter > 0;106 if( data.state != SIGNAL && running ) {107 sout | "ERROR Eager signal" | data.state;113 bool running = TEST(globals.data.counter < N) && globals.data.counter > 0; 114 if( globals.data.state != SIGNAL && running ) { 115 sout | "ERROR Eager signal" | globals.data.state; 108 116 } 109 117 } … … 116 124 void main( Signaller & this ) { 117 125 while( !all_done ) { 118 logic( mut );126 logic( globals.mut ); 119 127 yield(); 120 128 }
Note: See TracChangeset
for help on using the changeset viewer.