Changeset 3f7e12cb for src/tests/sched-int-wait.c
- Timestamp:
- Nov 8, 2017, 5:43:33 PM (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:
- 954908d
- Parents:
- 78315272 (diff), e35f30a (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-wait.c
r78315272 r3f7e12cb 1 //--------------------------------------------------------- 2 // Multi wait test 3 // Ensures that no deadlock from waiting/signalling conditions 4 //--------------------------------------------------------- 5 6 1 7 #include <fstream> 2 8 #include <kernel> … … 35 41 //---------------------------------------------------------------------------------------------------- 36 42 // Tools 37 void signal( condition *cond, global_t & mutex a, global_t & mutex b ) {43 void signal( condition & cond, global_t & mutex a, global_t & mutex b ) { 38 44 signal( cond ); 39 45 } 40 46 41 void signal( condition *cond, global_t & mutex a, global_t & mutex b, global_t & mutex c ) {47 void signal( condition & cond, global_t & mutex a, global_t & mutex b, global_t & mutex c ) { 42 48 signal( cond ); 43 49 } 44 50 45 void wait( condition *cond, global_t & mutex a, global_t & mutex b ) {51 void wait( condition & cond, global_t & mutex a, global_t & mutex b ) { 46 52 wait( cond ); 47 53 } 48 54 49 void wait( condition *cond, global_t & mutex a, global_t & mutex b, global_t & mutex c ) {55 void wait( condition & cond, global_t & mutex a, global_t & mutex b, global_t & mutex c ) { 50 56 wait( cond ); 51 57 } … … 56 62 57 63 while( waiter_left != 0 ) { 58 unsigned action = (unsigned)rand48() % 4;64 unsigned action = random( 4 ); 59 65 switch( action ) { 60 66 case 0: 61 signal( &condABC, globalA, globalB, globalC );67 signal( condABC, globalA, globalB, globalC ); 62 68 break; 63 69 case 1: 64 signal( &condAB , globalA, globalB );70 signal( condAB , globalA, globalB ); 65 71 break; 66 72 case 2: 67 signal( &condBC , globalB, globalC );73 signal( condBC , globalB, globalC ); 68 74 break; 69 75 case 3: 70 signal( &condAC , globalA, globalC );76 signal( condAC , globalA, globalC ); 71 77 break; 72 78 default: … … 82 88 void main( WaiterABC & this ) { 83 89 for( int i = 0; i < N; i++ ) { 84 wait( &condABC, globalA, globalB, globalC );90 wait( condABC, globalA, globalB, globalC ); 85 91 } 86 92 … … 92 98 void main( WaiterAB & this ) { 93 99 for( int i = 0; i < N; i++ ) { 94 wait( &condAB , globalA, globalB );100 wait( condAB , globalA, globalB ); 95 101 } 96 102 … … 102 108 void main( WaiterAC & this ) { 103 109 for( int i = 0; i < N; i++ ) { 104 wait( &condAC , globalA, globalC );110 wait( condAC , globalA, globalC ); 105 111 } 106 112 … … 112 118 void main( WaiterBC & this ) { 113 119 for( int i = 0; i < N; i++ ) { 114 wait( &condBC , globalB, globalC );120 wait( condBC , globalB, globalC ); 115 121 } 116 122 … … 121 127 // Main 122 128 int main(int argc, char* argv[]) { 123 rand 48seed( time( NULL ) );129 random_seed( time( NULL ) ); 124 130 waiter_left = 4; 125 131 processor p[2];
Note:
See TracChangeset
for help on using the changeset viewer.