Changeset 90152a4 for tests/concurrent/signal/block.c
- Timestamp:
- Aug 27, 2018, 4:40:34 PM (7 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum, stuck-waitfor-destruct
- Children:
- b7c89aa
- Parents:
- f9feab8 (diff), 305581d (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 moved
-
tests/concurrent/signal/block.c (moved) (moved from src/tests/concurrent/signal/block.c ) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrent/signal/block.c
rf9feab8 r90152a4 7 7 8 8 9 #include <fstream> 10 #include <kernel> 11 #include <monitor> 12 #include <stdlib> 13 #include <thread> 9 #include <fstream.hfa> 10 #include <kernel.hfa>hfa> 11 #include <monitor.hfa> 12 #include <stdlib.hfa> 13 #include <thread.hfa> 14 #include <time.hfa> 14 15 15 #include <time.h> 16 17 static const unsigned long N = 5_000ul; 16 #include "long_tests.h" 18 17 19 18 #ifndef PREEMPTION_RATE 20 #define PREEMPTION_RATE 10 _000ul19 #define PREEMPTION_RATE 10`ms 21 20 #endif 22 21 23 unsigned intdefault_preemption() {22 Duration default_preemption() { 24 23 return PREEMPTION_RATE; 25 24 } 25 26 #ifdef TEST_LONG 27 static const unsigned long N = 150_000ul; 28 #else 29 static const unsigned long N = 5_000ul; 30 #endif 26 31 27 32 enum state_t { WAITED, SIGNAL, BARGE }; … … 37 42 } 38 43 39 void ^?{} ( global_data_t & this ) {}44 void ^?{} ( global_data_t & mutex this ) {} 40 45 41 46 global_data_t globalA, globalB; … … 47 52 //------------------------------------------------------------------------------ 48 53 void wait_op( global_data_t & mutex a, global_data_t & mutex b, unsigned i ) { 49 wait( cond, (uintptr_t)this_thread);54 wait( cond, (uintptr_t)active_thread() ); 50 55 51 56 yield( random( 10 ) ); … … 56 61 } 57 62 58 a.last_thread = b.last_thread = this_thread;63 a.last_thread = b.last_thread = active_thread(); 59 64 60 65 yield( random( 10 ) ); … … 63 68 thread Waiter {}; 64 69 void main( Waiter & this ) { 65 for( int i = 0; i < N; i++ ) {70 for( int i = 0; TEST(i < N); i++ ) { 66 71 wait_op( globalA, globalB, i ); 72 KICK_WATCHDOG; 67 73 } 68 74 } … … 72 78 yield( random( 10 ) ); 73 79 74 [a.last_thread, b.last_thread, a.last_signaller, b.last_signaller] = this_thread;80 [a.last_thread, b.last_thread, a.last_signaller, b.last_signaller] = active_thread(); 75 81 76 82 if( !is_empty( cond ) ) { … … 102 108 //------------------------------------------------------------------------------ 103 109 void barge_op( global_data_t & mutex a ) { 104 a.last_thread = this_thread;110 a.last_thread = active_thread(); 105 111 } 106 112 … … 118 124 119 125 int main(int argc, char* argv[]) { 120 random_seed( time( NULL ) );126 srandom( time( NULL ) ); 121 127 done = false; 122 128 processor p;
Note:
See TracChangeset
for help on using the changeset viewer.