Changes in src/tests/sched-int-wait.c [303406a:4cedd9f]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/sched-int-wait.c
r303406a r4cedd9f 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 } … … 53 59 //---------------------------------------------------------------------------------------------------- 54 60 // Signaler 55 void main( Signaler *this ) {61 void main( Signaler & this ) { 56 62 57 63 while( waiter_left != 0 ) { 58 unsigned action = (unsigned)rand48() % 4;64 unsigned action = rand48(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: … … 80 86 //---------------------------------------------------------------------------------------------------- 81 87 // Waiter ABC 82 void main( WaiterABC *this ) {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 … … 90 96 //---------------------------------------------------------------------------------------------------- 91 97 // Waiter AB 92 void main( WaiterAB *this ) {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 … … 100 106 //---------------------------------------------------------------------------------------------------- 101 107 // Waiter AC 102 void main( WaiterAC *this ) {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 … … 110 116 //---------------------------------------------------------------------------------------------------- 111 117 // Waiter BC 112 void main( WaiterBC *this ) {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
Note:
See TracChangeset
for help on using the changeset viewer.