Changeset 58fe85a for tests/concurrent/signal/disjoint.cfa
- Timestamp:
- Jan 7, 2021, 3:27:00 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 2b4daf2, 64aeca0
- Parents:
- 3c64c668 (diff), eef8dfb (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
-
tests/concurrent/signal/disjoint.cfa (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrent/signal/disjoint.cfa
r3c64c668 r58fe85a 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 } … … 53 61 54 62 thread Barger {}; 63 void ?{}( Barger & this ) { 64 ((thread&)this){ "Barger Thread" }; 65 } 55 66 56 67 void main( Barger & this ) { 57 68 while( !all_done ) { 58 barge( data );69 barge( globals.data ); 59 70 yield(); 60 71 } … … 78 89 79 90 thread Waiter {}; 91 void ?{}( Waiter & this ) { 92 ((thread&)this){ "Waiter Thread" }; 93 } 80 94 81 95 void main( Waiter & this ) { 82 while( wait( mut,data ) ) { KICK_WATCHDOG; yield(); }96 while( wait( globals.mut, globals.data ) ) { KICK_WATCHDOG; yield(); } 83 97 } 84 98 … … 92 106 93 107 void logic( global_t & mutex a ) { 94 signal( cond, a, data );108 signal( cond, a, globals.data ); 95 109 96 110 yield( random( 10 ) ); 97 111 98 112 //This is technically a mutual exclusion violation but the mutex monitor protects us 99 bool running = TEST( data.counter < N) &&data.counter > 0;100 if( data.state != SIGNAL && running ) {101 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; 102 116 } 103 117 } 104 118 105 119 thread Signaller {}; 120 void ?{}( Signaller & this ) { 121 ((thread&)this){ "Signaller Thread" }; 122 } 106 123 107 124 void main( Signaller & this ) { 108 125 while( !all_done ) { 109 logic( mut );126 logic( globals.mut ); 110 127 yield(); 111 128 }
Note:
See TracChangeset
for help on using the changeset viewer.