Changeset db4062d for src/tests/concurrent
- Timestamp:
- Jun 20, 2018, 8:42:37 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, with_gc
- Children:
- 4439008
- Parents:
- e04aec4 (diff), 270fdcf (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. - Location:
- src/tests/concurrent
- Files:
-
- 5 edited
-
coroutineYield.c (modified) (4 diffs)
-
preempt.c (modified) (4 diffs)
-
signal/block.c (modified) (3 diffs)
-
signal/disjoint.c (modified) (5 diffs)
-
signal/wait.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/tests/concurrent/coroutineYield.c
re04aec4 rdb4062d 4 4 #include <thread> 5 5 #include <time> 6 7 #define __kick_rate 150000ul 8 #include "long_tests.h" 6 9 7 10 #ifndef PREEMPTION_RATE … … 13 16 } 14 17 15 #ifdef LONG_TEST18 #ifdef TEST_LONG 16 19 static const unsigned long N = 600_000ul; 17 20 #else … … 23 26 void main(Coroutine& this) { 24 27 while(true) { 25 sout | "Coroutine 1" | endl; 28 #if !defined(TEST_FOREVER) 29 sout | "Coroutine 1" | endl; 30 #endif 26 31 yield(); 27 sout | "Coroutine 2" | endl; 32 #if !defined(TEST_FOREVER) 33 sout | "Coroutine 2" | endl; 34 #endif 28 35 suspend(); 29 36 } … … 33 40 int main(int argc, char* argv[]) { 34 41 Coroutine c; 35 for(int i = 0; i < N; i++) { 36 sout | "Thread 1" | endl; 42 for(int i = 0; TEST(i < N); i++) { 43 #if !defined(TEST_FOREVER) 44 sout | "Thread 1" | endl; 45 #endif 37 46 resume(c); 38 sout | "Thread 2" | endl; 47 #if !defined(TEST_FOREVER) 48 sout | "Thread 2" | endl; 49 #endif 39 50 yield(); 51 KICK_WATCHDOG; 40 52 } 41 53 } -
src/tests/concurrent/preempt.c
re04aec4 rdb4062d 2 2 #include <thread> 3 3 #include <time> 4 5 #include "long_tests.h" 4 6 5 7 #ifndef PREEMPTION_RATE … … 11 13 } 12 14 13 #ifdef LONG_TEST15 #ifdef TEST_LONG 14 16 static const unsigned long N = 30_000ul; 15 17 #else … … 30 32 31 33 void main(worker_t & this) { 32 while( counter < N) {34 while(TEST(counter < N)) { 33 35 __cfaabi_check_preemption(); 34 36 if( (counter % 7) == this.value ) { … … 40 42 } 41 43 __cfaabi_check_preemption(); 44 KICK_WATCHDOG; 42 45 } 43 46 } -
src/tests/concurrent/signal/block.c
re04aec4 rdb4062d 14 14 #include <time> 15 15 16 #include "long_tests.h" 17 16 18 #ifndef PREEMPTION_RATE 17 19 #define PREEMPTION_RATE 10`ms … … 22 24 } 23 25 24 #ifdef LONG_TEST26 #ifdef TEST_LONG 25 27 static const unsigned long N = 150_000ul; 26 28 #else … … 66 68 thread Waiter {}; 67 69 void main( Waiter & this ) { 68 for( int i = 0; i < N; i++ ) {70 for( int i = 0; TEST(i < N); i++ ) { 69 71 wait_op( globalA, globalB, i ); 72 KICK_WATCHDOG; 70 73 } 71 74 } -
src/tests/concurrent/signal/disjoint.c
re04aec4 rdb4062d 4 4 #include <thread> 5 5 #include <time> 6 7 #include "long_tests.h" 6 8 7 9 #ifndef PREEMPTION_RATE … … 13 15 } 14 16 15 #ifdef LONG_TEST17 #ifdef TEST_LONG 16 18 static const unsigned long N = 300_000ul; 17 19 #else … … 67 69 } 68 70 69 d.counter++; 71 #if !defined(TEST_FOREVER) 72 d.counter++; 73 if( (d.counter % 1000) == 0 ) sout | d.counter | endl; 74 #endif 70 75 71 if( (d.counter % 1000) == 0 ) sout | d.counter | endl; 72 73 return d.counter < N; 76 return TEST(d.counter < N); 74 77 } 75 78 … … 77 80 78 81 void main( Waiter & this ) { 79 while( wait( mut, data ) ) { yield(); }82 while( wait( mut, data ) ) { KICK_WATCHDOG; yield(); } 80 83 } 81 84 … … 94 97 95 98 //This is technically a mutual exclusion violation but the mutex monitor protects us 96 bool running = data.counter < N&& data.counter > 0;99 bool running = TEST(data.counter < N) && data.counter > 0; 97 100 if( data.state != SIGNAL && running ) { 98 101 sout | "ERROR Eager signal" | data.state | endl; -
src/tests/concurrent/signal/wait.c
re04aec4 rdb4062d 12 12 #include <time> 13 13 14 #define __kick_rate 12000ul 15 #include "long_tests.h" 16 14 17 #ifndef PREEMPTION_RATE 15 18 #define PREEMPTION_RATE 10`ms … … 20 23 } 21 24 22 #ifdef LONG_TEST25 #ifdef TEST_LONG 23 26 static const unsigned long N = 375_000ul; 24 27 #else … … 90 93 // Waiter ABC 91 94 void main( WaiterABC & this ) { 92 for( int i = 0; i < N; i++ ) {95 for( int i = 0; TEST(i < N); i++ ) { 93 96 wait( condABC, globalA, globalB, globalC ); 97 KICK_WATCHDOG; 94 98 } 95 99 … … 100 104 // Waiter AB 101 105 void main( WaiterAB & this ) { 102 for( int i = 0; i < N; i++ ) {106 for( int i = 0; TEST(i < N); i++ ) { 103 107 wait( condAB , globalA, globalB ); 108 KICK_WATCHDOG; 104 109 } 105 110 … … 110 115 // Waiter AC 111 116 void main( WaiterAC & this ) { 112 for( int i = 0; i < N; i++ ) {117 for( int i = 0; TEST(i < N); i++ ) { 113 118 wait( condAC , globalA, globalC ); 119 KICK_WATCHDOG; 114 120 } 115 121 … … 120 126 // Waiter BC 121 127 void main( WaiterBC & this ) { 122 for( int i = 0; i < N; i++ ) {128 for( int i = 0; TEST(i < N); i++ ) { 123 129 wait( condBC , globalB, globalC ); 130 KICK_WATCHDOG; 124 131 } 125 132
Note:
See TracChangeset
for help on using the changeset viewer.